diff options
author | Bharat Mediratta <bharat@menalto.com> | 2009-06-28 16:24:51 -0700 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2009-06-28 16:24:51 -0700 |
commit | aa31e1f0090522c3cfb3a44b947ad8c33a275979 (patch) | |
tree | 0438427a2864b69228a48ff6670671d53ee7cf17 /modules/gallery/controllers/javascript.php | |
parent | f3f8b5eed6bbb4a1697db2ac5a7085439ed35a0d (diff) |
Tweak the cache implementation
1) Drop the *_modified key, we don't really need it. The modification date is not
relevant to our browser caching strategy.
2) Fix multiple issues with the Expires header and just hardcode it to the biggest
possibly value for code clarity.
3) print the $content out directly instead of using fwrite
4) Minor cleanups in the installer.
Diffstat (limited to 'modules/gallery/controllers/javascript.php')
-rw-r--r-- | modules/gallery/controllers/javascript.php | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/modules/gallery/controllers/javascript.php b/modules/gallery/controllers/javascript.php index bc231e0a..ba5cbf4b 100644 --- a/modules/gallery/controllers/javascript.php +++ b/modules/gallery/controllers/javascript.php @@ -27,16 +27,13 @@ class Javascript_Controller extends Controller { // We don't need to save the session for this request Session::abort_save(); - // Dump out the javascript file - $cache = Cache::instance(); - - $modified = $cache->get("{$key}_modified"); - if (!empty($_SERVER["HTTP_IF_MODIFIED_SINCE"]) && !empty($modified)) { + // Our data is immutable, so if they already have a copy then it needs no updating. + if (!empty($_SERVER["HTTP_IF_MODIFIED_SINCE"])) { header('HTTP/1.0 304 Not Modified'); return; } - $content = ""; + $cache = Cache::instance(); if (strpos($_SERVER["HTTP_ACCEPT_ENCODING"], "gzip") !== false ) { $content = $cache->get("{$key}_gz"); } @@ -51,19 +48,15 @@ class Javascript_Controller extends Controller { if (strpos($_SERVER["HTTP_ACCEPT_ENCODING"], "gzip") !== false) { header("Content-Encoding: gzip"); - header("Cache-Control: private, x-gzip-ok=\"public\""); + header("Cache-Control: public"); } header("Content-Type: text/javascript; charset=UTF-8"); - - header("Expires: " . gmdate(21474383647)); - header("Last-Modified: " . $modified); + header("Expires: Tue, 19 Jan 2038 00:00:00 GMT"); + header("Last-Modified: " . gmdate("D, d M Y H:i:s T", time())); Kohana::close_buffers(false); - - $handle = fopen("php://output", "wb"); - fwrite($handle, $content); - fclose($handle); + print $content; } } |