Subversion Repositories oidplus

Compare Revisions

Regard whitespace Rev 378 → Rev 379

/trunk/polyfill.min.js.php
28,13 → 28,16
 
define('MINIFY_POLYFILL', true);
 
define('POLYFILL_CACHE_MAX_AGE', 24*60*60);
define('POLYFILL_CACHE_MAX_AGE', 24*60*60); // 1 day
 
# ---
 
header('Content-Type:application/javascript');
require_once __DIR__ . '/includes/functions.inc.php';
 
if (!isset($_SERVER['HTTP_USER_AGENT'])) die('/* ERROR: No User Agent available */');
if (!isset($_SERVER['HTTP_USER_AGENT'])) {
$out = '/* ERROR: No User Agent available */';
httpOutWithETag($out, 'application/javascript', 'polyfill.js');
}
 
$ua = $_SERVER['HTTP_USER_AGENT'];
 
65,14 → 68,19
 
if (file_exists($cache_file)) {
$out = file_get_contents($cache_file);
 
// In case polyfill.io is down, don't delay further requests
// Instead, try again after the next max cache age
touch($cache_file);
} else {
die('/* ERROR: polyfill.io not available and no cache file exists! */');
$out = '/* ERROR: polyfill.io not available and no cache file exists! */';
httpOutWithETag($out, 'application/javascript', 'polyfill.js');
}
 
} else {
 
$ua = str_replace('*/', '', $ua);
$cont = '/* Polyfill '.$url.' for '.$ua.' */'.$cont; // TODO: escape
$cont = '/* Polyfill '.$url.' for '.$ua.' */'.$cont;
 
@file_put_contents($cache_file, $cont);
 
88,11 → 96,4
 
# ---
 
$etag = md5($out);
header("Etag: $etag");
header('Content-MD5: '.$etag); // RFC 2616 clause 14.15
if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && (trim($_SERVER['HTTP_IF_NONE_MATCH']) == $etag)) {
header("HTTP/1.1 304 Not Modified");
} else {
echo $out;
}
httpOutWithETag($out, 'application/javascript', 'polyfill.js');