diff --git a/classes/optimizer/Optimizer.class.php b/classes/optimizer/Optimizer.class.php index d004e2e2a..09e070bef 100644 --- a/classes/optimizer/Optimizer.class.php +++ b/classes/optimizer/Optimizer.class.php @@ -58,7 +58,6 @@ } if(!count($targets)) return $this->_getOptimizedRemoved($files); - $list_file_hash = md5($hash); $oCacheHandler = &CacheHandler::getInstance('template'); if($oCacheHandler->isSupport()){ diff --git a/classes/template/TemplateHandler.class.php b/classes/template/TemplateHandler.class.php index 2bbafa1e2..b2711a3e6 100644 --- a/classes/template/TemplateHandler.class.php +++ b/classes/template/TemplateHandler.class.php @@ -57,10 +57,11 @@ $oCacheHandler = &CacheHandler::getInstance('template'); if($oCacheHandler->isSupport()){ - $buff = $oCacheHandler->get('template:'.$tpl_file, filemtime(FileHandler::getRealPath($tpl_file))); + $cache_key = 'template:'.$_SERVER['HTTP_HOST'] . $tpl_file; + $buff = $oCacheHandler->get($cache_key, filemtime(FileHandler::getRealPath($tpl_file))); if(!$buff){ $buff = $this->_compileTplFile($tpl_file); - $oCacheHandler->put('template:'.$tpl_file, $buff); + $oCacheHandler->put($cache_key, $buff); } $output = $this->_fetch('', $buff, $tpl_path); diff --git a/common/script.php b/common/script.php index c6b730afc..57ce2b566 100644 --- a/common/script.php +++ b/common/script.php @@ -60,6 +60,7 @@ if($type == '.css'){ } else if($type == '.js') { $content_type = 'text/javascript'; } + header("Content-Type: ".$content_type."; charset=UTF-8"); // return 304 @@ -82,6 +83,12 @@ function useContentEncoding(){ return false; } +function getCacheKey($list){ + global $cache_support; + $content_encoding = useContentEncoding(); + return md5('optimized:' . $_SERVER['HTTP_HOST'] . ':' . join('',$list) . ($content_encoding?'gzip':'') ); +} + function printFileList($list){ global $mtime, $cache_support, $oCacheHandler; @@ -89,7 +96,7 @@ function printFileList($list){ $output = null; if($cache_support){ - $cache_key = md5('optimized:'. join('',$list) . ($content_encoding?'gzip':'') ); + $cache_key = getCacheKey($list); $output = $oCacheHandler->get($cache_key, $mtime); } @@ -225,7 +232,7 @@ if($type == '.js'){ $css[] = getRealPath($cache_file); } - $cache_key = md5('optimized:'. join('',$css) . ($content_encoding?'gzip':'') ); + $cache_key = getCacheKey($css); $buff = $oCacheHandler->get($cache_key, $mtime); if(!$buff){ $buff = ''; @@ -238,7 +245,6 @@ if($type == '.js'){ $oCacheHandler->put($cache_key, $buff); } - printFileList($css); }else{ foreach($list as $file){ $cache_file = $cache_path . md5($file); @@ -252,8 +258,8 @@ if($type == '.js'){ $css[] = getRealPath($cache_file); } - printFileList($css); } + printFileList($css); } ?>