From aa31e1f0090522c3cfb3a44b947ad8c33a275979 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 28 Jun 2009 16:24:51 -0700 Subject: 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. --- modules/gallery/controllers/javascript.php | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'modules/gallery/controllers/javascript.php') 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; } } -- cgit v1.2.3