diff --git a/e107_admin/cache.php b/e107_admin/cache.php index dd497543d..8bc5ec723 100644 --- a/e107_admin/cache.php +++ b/e107_admin/cache.php @@ -2,7 +2,7 @@ /* * e107 website system * - * Copyright (C) 2008-2009 e107 Inc (e107.org) + * Copyright (C) 2008-2010 e107 Inc (e107.org) * Released under the terms and conditions of the * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * @@ -83,6 +83,12 @@ if (isset($_POST['trigger_empty_cache'])) admin_page_cache_erase(e_CACHE_IMAGE, '*.cache\.bin'); e107::getAdminLog()->flushMessages(CACLAN_25); break; + + // used in standard page output and internal JS includes + case 'empty_browsercache': + e107::getConfig()->set('e_jslib_browser_cache', time())->save(false); + e107::getAdminLog()->flushMessages(CACLAN_25); + break; // all default: @@ -90,6 +96,7 @@ if (isset($_POST['trigger_empty_cache'])) $ec->clear_sys(); admin_page_cache_erase(e_CACHE_DB, '*.php'); admin_page_cache_erase(e_CACHE_IMAGE, '*.cache\.bin'); + e107::getConfig()->set('e_jslib_browser_cache', time())->save(false); e107::getAdminLog()->flushMessages(CACLAN_26); break; } @@ -172,6 +179,7 @@ $text = " 'empty_syscache' => CACLAN_16, 'empty_dbcache' => CACLAN_24, 'empty_imgcache' => CACLAN_25, + 'empty_browsercache' => CACLAN_27, ))." ".$frm->admin_button('trigger_empty_cache', LAN_DELETE, 'delete')." diff --git a/e107_handlers/js_manager.php b/e107_handlers/js_manager.php index 4e53debc0..f07d5ff7e 100644 --- a/e107_handlers/js_manager.php +++ b/e107_handlers/js_manager.php @@ -174,7 +174,7 @@ class e_jsmanager $this->setInAdmin(defset('e_ADMIN_AREA', false)); // Try to load browser cache id from core preferences - $this->setCacheId(e107::getPref('e_jslib_browser_cache', 0)); + $this->setCacheId(deftrue('e_NOCACHE') ? time() : e107::getPref('e_jslib_browser_cache')); // Load stored in preferences core lib paths ASAP - FIXME - find better way to store libs - array structure and separate table row $core_libs = e107::getPref('e_jslib_core'); diff --git a/e107_languages/English/admin/lan_cache.php b/e107_languages/English/admin/lan_cache.php index c9fb5212c..3be21b3e1 100644 --- a/e107_languages/English/admin/lan_cache.php +++ b/e107_languages/English/admin/lan_cache.php @@ -32,4 +32,5 @@ define("CACLAN_23", "Thumbnail cache files contains binary image data. They are define("CACLAN_24", "Empty DB Structure Cache"); define("CACLAN_25", "Empty Thumbnail Cache"); define("CACLAN_26", "Empty All Cache"); +define("CACLAN_27", "Empty Browser Cache"); ?> \ No newline at end of file diff --git a/e107_themes/templates/footer_default.php b/e107_themes/templates/footer_default.php index 76ff55100..5d3531bd8 100644 --- a/e107_themes/templates/footer_default.php +++ b/e107_themes/templates/footer_default.php @@ -288,6 +288,8 @@ if (abs($_serverTime - $lastSet) > 120) // // H Final HTML // +// browser cache control +echo "\n\n"; echo ""; // @@ -297,6 +299,7 @@ $page = ob_get_clean(); $etag = md5($page); +//header('Pragma:'); // previously disabled or there is posted data if(!deftrue('e_NOCACHE') && empty($_POST)) { diff --git a/thumb.php b/thumb.php index e4befc8ba..0d07eda6d 100644 --- a/thumb.php +++ b/thumb.php @@ -178,6 +178,9 @@ class e_thumbpage $thumbnfo['lmodified'] = filemtime(e_CACHE_IMAGE.$fname); $thumbnfo['md5s'] = md5_file(e_CACHE_IMAGE.$fname); $thumbnfo['fsize'] = filesize(e_CACHE_IMAGE.$fname); + + // Send required headers + $this->sendHeaders($thumbnfo); // check browser cache if (@$_SERVER['HTTP_IF_MODIFIED_SINCE'] && ($thumbnfo['lmodified'] <= strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])) && (isset($_SERVER['HTTP_IF_NONE_MATCH']) && trim($_SERVER['HTTP_IF_NONE_MATCH']) == $thumbnfo['md5s'])) @@ -188,7 +191,7 @@ class e_thumbpage } // Send required headers - $this->sendHeaders($thumbnfo); + //$this->sendHeaders($thumbnfo); @readfile(e_CACHE_IMAGE.$fname); //$bench->end()->logResult('thumb.php', $_GET['src'].' - retrieve cache'); @@ -241,7 +244,11 @@ class e_thumbpage echo 'Headers already sent! '; exit; } - + if (function_exists('date_default_timezone_set')) + { + date_default_timezone_set('UTC'); + } + //header('Pragma:'); header('Cache-Control: must-revalidate'); header('Last-Modified: '.gmdate('D, d M Y H:i:s', $thumbnfo['lmodified']).' GMT'); header('Content-Length: '.$thumbnfo['fsize']);