summaryrefslogtreecommitdiff
path: root/lib/exe/css.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/exe/css.php')
-rw-r--r--lib/exe/css.php68
1 files changed, 9 insertions, 59 deletions
diff --git a/lib/exe/css.php b/lib/exe/css.php
index e4105b427..9751b5be4 100644
--- a/lib/exe/css.php
+++ b/lib/exe/css.php
@@ -46,7 +46,7 @@ function css_out(){
}
// The generated script depends on some dynamic options
- $cache = getCacheName('styles'.$_SERVER['HTTP_HOST'].$_SERVER['SERVER_PORT'].DOKU_BASE.$tplinc.$mediatype,'.css');
+ $cache = new cache('styles'.$_SERVER['HTTP_HOST'].$_SERVER['SERVER_PORT'].DOKU_BASE.$tplinc.$mediatype,'.css');
// load template styles
$tplstyles = array();
@@ -87,26 +87,14 @@ function css_out(){
}
}
- // check cache age & handle conditional request
- header('Cache-Control: public, max-age=3600');
- header('Pragma: public');
- if(css_cacheok($cache,array_keys($files),$tplinc)){
- http_conditionalRequest(filemtime($cache));
- if($conf['allowdebug']) header("X-CacheUsed: $cache");
-
- // finally send output
- if ($conf['gzip_output'] && http_gzip_valid($cache)) {
- header('Vary: Accept-Encoding');
- header('Content-Encoding: gzip');
- readfile($cache.".gz");
- } else {
- if (!http_sendfile($cache)) readfile($cache);
- }
+ $cache_files = array_merge(array_keys($files), getConfigFiles('main'));
+ $cache_files[] = $tplinc.'style.ini';
+ $cache_files[] = __FILE__;
- return;
- } else {
- http_conditionalRequest(time());
- }
+ // check cache age & handle conditional request
+ // This may exit if a cache can be used
+ http_cached($cache->cache,
+ $cache->useCache(array('files' => $cache_files)));
// start output buffering and build the stylesheet
ob_start();
@@ -135,45 +123,7 @@ function css_out(){
$css = css_compress($css);
}
- // save cache file
- io_saveFile($cache,$css);
- if(function_exists('gzopen')) io_saveFile("$cache.gz",$css);
-
- // finally send output
- if ($conf['gzip_output']) {
- header('Vary: Accept-Encoding');
- header('Content-Encoding: gzip');
- print gzencode($css,9,FORCE_GZIP);
- } else {
- print $css;
- }
-}
-
-/**
- * Checks if a CSS Cache file still is valid
- *
- * @author Andreas Gohr <andi@splitbrain.org>
- */
-function css_cacheok($cache,$files,$tplinc){
- global $config_cascade;
-
- if(isset($_REQUEST['purge'])) return false; //support purge request
-
- $ctime = @filemtime($cache);
- if(!$ctime) return false; //There is no cache
-
- // some additional files to check
- $files = array_merge($files, getConfigFiles('main'));
- $files[] = $tplinc.'style.ini';
- $files[] = __FILE__;
-
- // now walk the files
- foreach($files as $file){
- if(@filemtime($file) > $ctime){
- return false;
- }
- }
- return true;
+ http_cached_finish($cache->cache, $css);
}
/**