1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 04:38:27 +01:00

improved browser cache control, clear browser cache added to cache administration

This commit is contained in:
secretr 2010-12-17 17:21:48 +00:00
parent eb057e6492
commit f3ab862313
5 changed files with 23 additions and 4 deletions

View File

@ -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')."
</div>

View File

@ -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');

View File

@ -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");
?>

View File

@ -288,6 +288,8 @@ if (abs($_serverTime - $lastSet) > 120)
//
// H Final HTML
//
// browser cache control
echo "\n<!-- ".md5(deftrue('e_NOCACHE') ? time() : e107::getPref('e_jslib_browser_cache'))." -->\n";
echo "</body></html>";
//
@ -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))
{

View File

@ -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']);