mirror of
https://github.com/e107inc/e107.git
synced 2025-01-17 20:58:30 +01:00
improved browser cache control, clear browser cache added to cache administration
This commit is contained in:
parent
eb057e6492
commit
f3ab862313
@ -2,7 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
* e107 website system
|
* 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
|
* Released under the terms and conditions of the
|
||||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||||
*
|
*
|
||||||
@ -84,12 +84,19 @@ if (isset($_POST['trigger_empty_cache']))
|
|||||||
e107::getAdminLog()->flushMessages(CACLAN_25);
|
e107::getAdminLog()->flushMessages(CACLAN_25);
|
||||||
break;
|
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
|
// all
|
||||||
default:
|
default:
|
||||||
$ec->clear();
|
$ec->clear();
|
||||||
$ec->clear_sys();
|
$ec->clear_sys();
|
||||||
admin_page_cache_erase(e_CACHE_DB, '*.php');
|
admin_page_cache_erase(e_CACHE_DB, '*.php');
|
||||||
admin_page_cache_erase(e_CACHE_IMAGE, '*.cache\.bin');
|
admin_page_cache_erase(e_CACHE_IMAGE, '*.cache\.bin');
|
||||||
|
e107::getConfig()->set('e_jslib_browser_cache', time())->save(false);
|
||||||
e107::getAdminLog()->flushMessages(CACLAN_26);
|
e107::getAdminLog()->flushMessages(CACLAN_26);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -172,6 +179,7 @@ $text = "
|
|||||||
'empty_syscache' => CACLAN_16,
|
'empty_syscache' => CACLAN_16,
|
||||||
'empty_dbcache' => CACLAN_24,
|
'empty_dbcache' => CACLAN_24,
|
||||||
'empty_imgcache' => CACLAN_25,
|
'empty_imgcache' => CACLAN_25,
|
||||||
|
'empty_browsercache' => CACLAN_27,
|
||||||
))."
|
))."
|
||||||
".$frm->admin_button('trigger_empty_cache', LAN_DELETE, 'delete')."
|
".$frm->admin_button('trigger_empty_cache', LAN_DELETE, 'delete')."
|
||||||
</div>
|
</div>
|
||||||
|
@ -174,7 +174,7 @@ class e_jsmanager
|
|||||||
$this->setInAdmin(defset('e_ADMIN_AREA', false));
|
$this->setInAdmin(defset('e_ADMIN_AREA', false));
|
||||||
|
|
||||||
// Try to load browser cache id from core preferences
|
// 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
|
// 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');
|
$core_libs = e107::getPref('e_jslib_core');
|
||||||
|
@ -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_24", "Empty DB Structure Cache");
|
||||||
define("CACLAN_25", "Empty Thumbnail Cache");
|
define("CACLAN_25", "Empty Thumbnail Cache");
|
||||||
define("CACLAN_26", "Empty All Cache");
|
define("CACLAN_26", "Empty All Cache");
|
||||||
|
define("CACLAN_27", "Empty Browser Cache");
|
||||||
?>
|
?>
|
@ -288,6 +288,8 @@ if (abs($_serverTime - $lastSet) > 120)
|
|||||||
//
|
//
|
||||||
// H Final HTML
|
// H Final HTML
|
||||||
//
|
//
|
||||||
|
// browser cache control
|
||||||
|
echo "\n<!-- ".md5(deftrue('e_NOCACHE') ? time() : e107::getPref('e_jslib_browser_cache'))." -->\n";
|
||||||
echo "</body></html>";
|
echo "</body></html>";
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -297,6 +299,7 @@ $page = ob_get_clean();
|
|||||||
|
|
||||||
$etag = md5($page);
|
$etag = md5($page);
|
||||||
|
|
||||||
|
//header('Pragma:');
|
||||||
// previously disabled or there is posted data
|
// previously disabled or there is posted data
|
||||||
if(!deftrue('e_NOCACHE') && empty($_POST))
|
if(!deftrue('e_NOCACHE') && empty($_POST))
|
||||||
{
|
{
|
||||||
|
11
thumb.php
11
thumb.php
@ -179,6 +179,9 @@ class e_thumbpage
|
|||||||
$thumbnfo['md5s'] = md5_file(e_CACHE_IMAGE.$fname);
|
$thumbnfo['md5s'] = md5_file(e_CACHE_IMAGE.$fname);
|
||||||
$thumbnfo['fsize'] = filesize(e_CACHE_IMAGE.$fname);
|
$thumbnfo['fsize'] = filesize(e_CACHE_IMAGE.$fname);
|
||||||
|
|
||||||
|
// Send required headers
|
||||||
|
$this->sendHeaders($thumbnfo);
|
||||||
|
|
||||||
// check browser cache
|
// 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']))
|
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
|
// Send required headers
|
||||||
$this->sendHeaders($thumbnfo);
|
//$this->sendHeaders($thumbnfo);
|
||||||
|
|
||||||
@readfile(e_CACHE_IMAGE.$fname);
|
@readfile(e_CACHE_IMAGE.$fname);
|
||||||
//$bench->end()->logResult('thumb.php', $_GET['src'].' - retrieve cache');
|
//$bench->end()->logResult('thumb.php', $_GET['src'].' - retrieve cache');
|
||||||
@ -241,7 +244,11 @@ class e_thumbpage
|
|||||||
echo 'Headers already sent! ';
|
echo 'Headers already sent! ';
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
if (function_exists('date_default_timezone_set'))
|
||||||
|
{
|
||||||
|
date_default_timezone_set('UTC');
|
||||||
|
}
|
||||||
|
//header('Pragma:');
|
||||||
header('Cache-Control: must-revalidate');
|
header('Cache-Control: must-revalidate');
|
||||||
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $thumbnfo['lmodified']).' GMT');
|
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $thumbnfo['lmodified']).' GMT');
|
||||||
header('Content-Length: '.$thumbnfo['fsize']);
|
header('Content-Length: '.$thumbnfo['fsize']);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user