// 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 {
$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")) {
// 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');