mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-09 12:02:24 +09:00
r7451 보완
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@7454 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
40eb9c776e
commit
3d738e713a
1 changed files with 18 additions and 14 deletions
|
|
@ -4,6 +4,7 @@
|
||||||
* @brief css 및 js Optimizer 처리 gateway
|
* @brief css 및 js Optimizer 처리 gateway
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
if(!$_GET['t'] || !$_GET['l']) exit;
|
if(!$_GET['t'] || !$_GET['l']) exit;
|
||||||
|
|
||||||
// set env
|
// set env
|
||||||
|
|
@ -62,7 +63,6 @@ if($type == '.css'){
|
||||||
}
|
}
|
||||||
|
|
||||||
header("Content-Type: ".$content_type."; charset=UTF-8");
|
header("Content-Type: ".$content_type."; charset=UTF-8");
|
||||||
|
|
||||||
// return 304
|
// return 304
|
||||||
if (!empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
|
if (!empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
|
||||||
$modifiedSince = strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']);
|
$modifiedSince = strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']);
|
||||||
|
|
@ -72,7 +72,6 @@ if (!empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function useContentEncoding(){
|
function useContentEncoding(){
|
||||||
if( (defined('__OB_GZHANDLER_ENABLE__') && __OB_GZHANDLER_ENABLE__ == 1)
|
if( (defined('__OB_GZHANDLER_ENABLE__') && __OB_GZHANDLER_ENABLE__ == 1)
|
||||||
&& strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')!==false
|
&& strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')!==false
|
||||||
|
|
@ -86,7 +85,9 @@ function useContentEncoding(){
|
||||||
function getCacheKey($list){
|
function getCacheKey($list){
|
||||||
global $cache_support;
|
global $cache_support;
|
||||||
$content_encoding = useContentEncoding();
|
$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){
|
function printFileList($list){
|
||||||
|
|
@ -100,7 +101,7 @@ function printFileList($list){
|
||||||
$output = $oCacheHandler->get($cache_key, $mtime);
|
$output = $oCacheHandler->get($cache_key, $mtime);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$output){
|
if(!$output || trim($output)==''){
|
||||||
for($i=0,$c=count($list);$i<$c;$i++){
|
for($i=0,$c=count($list);$i<$c;$i++){
|
||||||
$file = getRealPath($list[$i]);
|
$file = getRealPath($list[$i]);
|
||||||
if(file_exists($file)){
|
if(file_exists($file)){
|
||||||
|
|
@ -114,11 +115,20 @@ function printFileList($list){
|
||||||
|
|
||||||
if($cache_support) $oCacheHandler->put($cache_key, $output);
|
if($cache_support) $oCacheHandler->put($cache_key, $output);
|
||||||
|
|
||||||
if($content_encoding){
|
$size = strlen($output);
|
||||||
header("Content-Encoding: gzip");
|
|
||||||
|
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;
|
echo $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -215,13 +225,6 @@ function convertEncodingStr($str) {
|
||||||
return $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'){
|
if($type == '.js'){
|
||||||
printFileList($list);
|
printFileList($list);
|
||||||
}else if($type == '.css'){
|
}else if($type == '.css'){
|
||||||
|
|
@ -236,6 +239,7 @@ if($type == '.js'){
|
||||||
$buff = $oCacheHandler->get($cache_key, $mtime);
|
$buff = $oCacheHandler->get($cache_key, $mtime);
|
||||||
if(!$buff){
|
if(!$buff){
|
||||||
$buff = '';
|
$buff = '';
|
||||||
|
$css = array();
|
||||||
foreach($list as $file){
|
foreach($list as $file){
|
||||||
$cache_file = $cache_path . md5($file);
|
$cache_file = $cache_path . md5($file);
|
||||||
$buff .= makeCacheFileCSS($file, getRealPath($cache_file), true);
|
$buff .= makeCacheFileCSS($file, getRealPath($cache_file), true);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue