PluginProbe
Autoptimize / 1.2
Autoptimize v1.2
2.2.2 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.5.0 2.5.1 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 All 107 releases
← All changes | config/delayed.php +22 -39 2.3.21.2 View file →
@@ -40,47 +40,30 @@
40 40 //Get data
41 41 $contents = file_get_contents(__FILE__.'.'.$encoding);
42 42 }
43 43
44 -// first check if we have to send 304
45 -// inspired by http://www.jonasjohn.de/snippets/php/caching.htm
44 +if ($encoding != 'none')
45 +{
46 + // Send compressed contents
47 + header('Content-Encoding: '.$encoding);
48 +}
49 +header('Vary: Accept-Encoding');
50 +header('Content-Length: '.strlen($contents));
46 51
47 -$eTag=md5($contents);
48 -$modTime=filemtime(__FILE__.'.none');
52 +header('Content-type: %%CONTENT%%; charset=utf-8');
53 +header('Cache-Control: max-age=315360000, public, must-revalidate');
54 +header('Expires: '.gmdate('D, d M Y H:i:s', time() + 315360000).' GMT'); //10 years
49 55
50 -date_default_timezone_set("UTC");
51 -$eTagMatch = (isset($_SERVER['HTTP_IF_NONE_MATCH']) && strpos($_SERVER['HTTP_IF_NONE_MATCH'],$eTag));
52 -$modTimeMatch = (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) === $modTime);
56 +echo $contents;
53 57
54 -if (($modTimeMatch)||($eTagMatch)) {
55 - header('HTTP/1.1 304 Not Modified');
56 - header('Connection: close');
57 -} else {
58 - // send all sorts of headers
59 - $expireTime=60*60*24*355; // 1y max according to RFC
60 - if ($encoding != 'none') {
61 - header('Content-Encoding: '.$encoding);
62 - }
63 - header('Vary: Accept-Encoding');
64 - header('Content-Length: '.strlen($contents));
65 - header('Content-type: %%CONTENT%%; charset=utf-8');
66 - header('Cache-Control: max-age='.$expireTime.', public, immutable');
67 - header('Expires: '.gmdate('D, d M Y H:i:s', time() + $expireTime).' GMT');
68 - header('ETag: ' . $eTag);
69 - header('Last-Modified: '.gmdate('D, d M Y H:i:s', $modTime).' GMT');
70 -
71 - // send output
72 - echo $contents;
73 -
74 - //And write to filesystem cache if not done yet
75 - if($encoding != 'none' && $iscompressed == false)
76 - {
77 - //Write the content we sent
78 - file_put_contents(__FILE__.'.'.$encoding,$contents);
79 -
80 - //And write the new content
81 - $flag = ($encoding == 'gzip' ? FORCE_DEFLATE : FORCE_GZIP);
82 - $ext = ($encoding == 'gzip' ? 'deflate' : 'gzip');
83 - $contents = gzencode($code,9,$flag);
84 - file_put_contents(__FILE__.'.'.$ext,$contents);
85 - }
58 +//Write it here
59 +if($encoding != 'none' && $iscompressed == false)
60 +{
61 + //Write the content we sent
62 + file_put_contents(__FILE__.'.'.$encoding,$contents);
63 +
64 + //And write the new content
65 + $flag = ($encoding == 'gzip' ? FORCE_DEFLATE : FORCE_GZIP);
66 + $ext = ($encoding == 'gzip' ? 'deflate' : 'gzip');
67 + $contents = gzencode($code,9,$flag);
68 + file_put_contents(__FILE__.'.'.$ext,$contents);
86 69 }