]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-21208 THEME_DESIGNER_CACHE_LIFETIME control option added
authorPetr Skoda <skodak@moodle.org>
Tue, 29 Dec 2009 12:14:42 +0000 (12:14 +0000)
committerPetr Skoda <skodak@moodle.org>
Tue, 29 Dec 2009 12:14:42 +0000 (12:14 +0000)
lib/outputlib.php
theme/styles_debug.php

index a8037822c1930c205c9e1b67486133aa447df3ab..c643030921152b9cdd410b8aed703aa2ef302129 100644 (file)
@@ -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 {
index 1db692b4f995be66356eae3205907bf06d2e741e..ead1ed89ec898b7acb9fedb58a18a01e7ae419af 100644 (file)
@@ -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');