From: Petr Skoda Date: Tue, 29 Dec 2009 12:14:42 +0000 (+0000) Subject: MDL-21208 THEME_DESIGNER_CACHE_LIFETIME control option added X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=d6b64d158307151b38495f76499850131b5c2567;p=moodle.git MDL-21208 THEME_DESIGNER_CACHE_LIFETIME control option added --- diff --git a/lib/outputlib.php b/lib/outputlib.php index a8037822c1..c643030921 100644 --- a/lib/outputlib.php +++ b/lib/outputlib.php @@ -590,13 +590,16 @@ class theme_config { // find out the current CSS and cache it now for 5 seconds // the point is to construct the CSS only once and pass it through the // dataroot to the script that actually serves the sheets + if (!defined('THEME_DESIGNER_CACHE_LIFETIME')) { + define('THEME_DESIGNER_CACHE_LIFETIME', 4); // this can be also set in config.php + } $candidatesheet = "$CFG->dataroot/cache/theme/$this->name/designer.ser"; if (!file_exists($candidatesheet)) { $css = $this->css_content(); check_dir_exists(dirname($candidatesheet), true, true); file_put_contents($candidatesheet, serialize($css)); - } else if (filemtime($candidatesheet) > time() - 5) { + } else if (filemtime($candidatesheet) > time() - THEME_DESIGNER_CACHE_LIFETIME) { if ($css = file_get_contents($candidatesheet)) { $css = unserialize($css); } else { diff --git a/theme/styles_debug.php b/theme/styles_debug.php index 1db692b4f9..ead1ed89ec 100644 --- a/theme/styles_debug.php +++ b/theme/styles_debug.php @@ -32,6 +32,10 @@ $type = min_optional_param('type', 'all', 'SAFEDIR'); $subtype = min_optional_param('subtype', '', 'SAFEDIR'); $sheet = min_optional_param('sheet', '', 'SAFEDIR'); +if (!defined('THEME_DESIGNER_CACHE_LIFETIME')) { + define('THEME_DESIGNER_CACHE_LIFETIME', 4); // this can be also set in config.php +} + if (file_exists("$CFG->dirroot/theme/$themename/config.php")) { // exists } else if (!empty($CFG->themedir) and file_exists("$CFG->themedir/$themename/config.php")) { @@ -77,7 +81,7 @@ css_not_found(); // we are not using filelib because we need to fine tune all header // parameters to get the best performance. -function send_uncached_css($css, $lifetime = 2) { +function send_uncached_css($css, $lifetime = THEME_DESIGNER_CACHE_LIFETIME) { header('Content-Disposition: inline; filename="styles_debug.php"'); header('Last-Modified: '. gmdate('D, d M Y H:i:s', time()) .' GMT'); header('Expires: '. gmdate('D, d M Y H:i:s', time() + $lifetime) .' GMT');