From 3d738e713afd085d33564878baebb90b947c4825 Mon Sep 17 00:00:00 2001 From: ngleader Date: Thu, 13 May 2010 03:24:52 +0000 Subject: [PATCH] =?UTF-8?q?r7451=20=EB=B3=B4=EC=99=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://xe-core.googlecode.com/svn/sandbox@7454 201d5d3c-b55e-5fd7-737f-ddc643e51545 --- common/script.php | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/common/script.php b/common/script.php index 57ce2b566..98366457c 100644 --- a/common/script.php +++ b/common/script.php @@ -4,6 +4,7 @@ * @brief css 및 js Optimizer 처리 gateway * **/ + if(!$_GET['t'] || !$_GET['l']) exit; // set env @@ -62,7 +63,6 @@ if($type == '.css'){ } header("Content-Type: ".$content_type."; charset=UTF-8"); - // return 304 if (!empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { $modifiedSince = strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']); @@ -72,7 +72,6 @@ if (!empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { exit; } } - function useContentEncoding(){ if( (defined('__OB_GZHANDLER_ENABLE__') && __OB_GZHANDLER_ENABLE__ == 1) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')!==false @@ -86,7 +85,9 @@ function useContentEncoding(){ function getCacheKey($list){ global $cache_support; $content_encoding = useContentEncoding(); - return md5('optimized:' . $_SERVER['HTTP_HOST'] . ':' . join('',$list) . ($content_encoding?'gzip':'') ); + $key = 'optimized:' . join('',$list); + $key .= $content_encoding?'gzip':'none'; + return $key; } function printFileList($list){ @@ -100,7 +101,7 @@ function printFileList($list){ $output = $oCacheHandler->get($cache_key, $mtime); } - if(!$output){ + if(!$output || trim($output)==''){ for($i=0,$c=count($list);$i<$c;$i++){ $file = getRealPath($list[$i]); if(file_exists($file)){ @@ -114,11 +115,20 @@ function printFileList($list){ if($cache_support) $oCacheHandler->put($cache_key, $output); - if($content_encoding){ - header("Content-Encoding: gzip"); + $size = strlen($output); + + if($size > 0){ + header("Cache-Control: private, max-age=2592000"); + header("Pragma: cache"); + header("Connection: close"); + header("Last-Modified: " . substr(gmdate('r', $mtime), 0, -5). "GMT"); + header("ETag: \"". md5(join(' ', $list)) .'-'. dechex($mtime) .'-'.dechex($size)."\""); } - header("Content-Length: ". strlen($output)); + header("Content-Length: ". $size); + + if($content_encoding) header("Content-Encoding: gzip"); + echo $output; } @@ -215,13 +225,6 @@ function convertEncodingStr($str) { return $str; } -// 200 -header("Cache-Control: private, max-age=2592000"); -header("Pragma: cache"); -header("Connection: close"); -header("Last-Modified: " . substr(gmdate('r', $mtime), 0, -5). "GMT"); -header("ETag: \"". md5(join(' ', $list)) .'-'. dechex($mtime)."\""); - if($type == '.js'){ printFileList($list); }else if($type == '.css'){ @@ -236,6 +239,7 @@ if($type == '.js'){ $buff = $oCacheHandler->get($cache_key, $mtime); if(!$buff){ $buff = ''; + $css = array(); foreach($list as $file){ $cache_file = $cache_path . md5($file); $buff .= makeCacheFileCSS($file, getRealPath($cache_file), true);