| @@ -1,12 +1,5 @@ | ||
| 1 | 1 | <?php exit; |
| 2 | - | |
| 3 | -//Check everything exists before using it | |
| 4 | -if(!isset($_SERVER['HTTP_ACCEPT_ENCODING'])) | |
| 5 | - $_SERVER['HTTP_ACCEPT_ENCODING'] = ''; | |
| 6 | -if(!isset($_SERVER['HTTP_USER_AGENT'])) | |
| 7 | - $_SERVER['HTTP_USER_AGENT'] = ''; | |
| 8 | - | |
| 9 | 2 | // Determine supported compression method |
| 10 | 3 | $gzip = strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip'); |
| 11 | 4 | $deflate = strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate'); |
| 12 | 5 | |
| @@ -25,41 +18,20 @@ | ||
| 25 | 18 | if ($version == 6 && !strstr($_SERVER['HTTP_USER_AGENT'], 'EV1')) |
| 26 | 19 | $encoding = 'none'; |
| 27 | 20 | } |
| 28 | 21 | |
| 29 | -//Some servers compress the output of PHP - Don't break in those cases | |
| 30 | -if(ini_get('output_handler') == 'ob_gzhandler' || ini_get('zlib.output_compression') == 1) | |
| 31 | - $encoding = 'none'; | |
| 32 | - | |
| 33 | 22 | //Get data |
| 34 | 23 | $contents = file_get_contents(__FILE__.'.'.$encoding); |
| 35 | 24 | |
| 36 | -// first check if we have to send 304 | |
| 37 | -$eTag=md5($contents); | |
| 38 | -$modTime=filemtime(__FILE__.'.none'); | |
| 25 | +if (isset($encoding) && $encoding != 'none') | |
| 26 | +{ | |
| 27 | + // Send compressed contents | |
| 28 | + header('Content-Encoding: '.$encoding); | |
| 29 | + header('Content-Length: '.strlen($contents)); | |
| 30 | +} | |
| 31 | +header('Vary: Accept-Encoding'); | |
| 39 | 32 | |
| 40 | -date_default_timezone_set("UTC"); | |
| 41 | -$eTagMatch = (isset($_SERVER['HTTP_IF_NONE_MATCH']) && strpos($_SERVER['HTTP_IF_NONE_MATCH'],$eTag)); | |
| 42 | -$modTimeMatch = (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) === $modTime); | |
| 33 | +header('Content-type: %%CONTENT%%; charset=utf-8'); | |
| 34 | +header('Cache-Control: max-age=315360000, public, must-revalidate'); | |
| 35 | +header('Expires: '.gmdate('D, d M Y H:i:s', time() + 315360000).' GMT'); //10 years | |
| 43 | 36 | |
| 44 | -if (($modTimeMatch)||($eTagMatch)) { | |
| 45 | - header('HTTP/1.1 304 Not Modified'); | |
| 46 | - header('Connection: close'); | |
| 47 | -} else { | |
| 48 | - // send all sorts of headers | |
| 49 | - $expireTime=60*60*24*356; // 1y max according to RFC | |
| 50 | - | |
| 51 | - if(isset($encoding) && $encoding != 'none') | |
| 52 | - { | |
| 53 | - header('Content-Encoding: '.$encoding); | |
| 54 | - } | |
| 55 | - header('Vary: Accept-Encoding'); | |
| 56 | - header('Content-Length: '.strlen($contents)); | |
| 57 | - header('Content-type: %%CONTENT%%; charset=utf-8'); | |
| 58 | - header('Cache-Control: max-age='.$expireTime.', public, immutable'); | |
| 59 | - header('Expires: '.gmdate('D, d M Y H:i:s', time() + $expireTime).' GMT'); //10 years | |
| 60 | - header('ETag: ' . $eTag); | |
| 61 | - header('Last-Modified: '.gmdate('D, d M Y H:i:s', $modTime).' GMT'); | |
| 62 | - | |
| 63 | - // send output | |
| 64 | - echo $contents; | |
| 65 | -} | |
| 37 | +echo $contents; | |