mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-29 15:22:15 +09:00
optimizer 사용시 캐시 파일명을 아예 변경하여 브라우저 캐시 문제를 근본적으로 해결
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@3521 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
814b0e8fbc
commit
f9557205a6
1 changed files with 14 additions and 10 deletions
|
|
@ -62,10 +62,21 @@
|
|||
|
||||
/**
|
||||
* @brief optimize는 대상 파일을 \n로 연결후 md5 hashing하여 파일이름의 중복을 피함
|
||||
* 개별 파일과 optimizer 클래스 파일의 변경을 적용하기 위해 각 파일들과 Optimizer.class.php의 filemtime을 비교, 파일이름에 반영
|
||||
**/
|
||||
function getHashFilename($files) {
|
||||
$count = count($files);
|
||||
$last_modified = 0;
|
||||
for($i=0;$i<$count;$i++) {
|
||||
$mtime = filemtime($files[$i]);
|
||||
if($last_modified < $mtime) $last_modified = $mtime;
|
||||
}
|
||||
|
||||
$mtime = filemtime('./classes/optimizer/Optimizer.class.php');
|
||||
if($last_modified < $mtime) $last_modified = $mtime;
|
||||
|
||||
$buff = implode("\n", $files);
|
||||
return md5($buff);
|
||||
return md5($buff).'.'.$last_modified;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -73,13 +84,6 @@
|
|||
**/
|
||||
function doOptimizedFile($filename, $targets, $type) {
|
||||
if(!file_exists($filename)) return $this->makeOptimizedFile($filename, $targets, $type);
|
||||
|
||||
if(filemtime($filename) < filemtime('./classes/optimizer/Optimizer.class.php')) return $this->makeOptimizedFile($filename, $targets, $type);
|
||||
|
||||
$mtime = filemtime($filename);
|
||||
foreach($targets as $file) {
|
||||
if($mtime < filemtime($file)) return $this->makeOptimizedFile($filename, $targets, $type);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -107,7 +111,7 @@
|
|||
FileHandler::writeFile($content_file, $content_buff);
|
||||
|
||||
/**
|
||||
* 압축을 지원하고 캐시 타임을 제대로 이용하기 위한 헤더 파일 구함
|
||||
* 캐시 타임을 제대로 이용하기 위한 헤더 파일 구함
|
||||
**/
|
||||
// 확장자별 content-type 체크
|
||||
if($type == 'css') $content_type = 'text/css';
|
||||
|
|
@ -134,7 +138,7 @@ if(isset($_SERVER["HTTP_IF_MODIFIED_SINCE"])) {
|
|||
header("Content-Type: '.$content_type.'; charset=utf-8");
|
||||
header("Date: '.substr(gmdate('r'), 0, -5).'GMT");
|
||||
header("Expires: '.substr(gmdate('r', strtotime('+1 MONTH')), 0, -5).'GMT");
|
||||
header("Cache-Control: private, max-age=86400");
|
||||
header("Cache-Control: private, max-age=2678400");
|
||||
header("Pragma: cache");
|
||||
header("Last-Modified: '.substr(gmdate('r', $mtime), 0, -5).'GMT");
|
||||
header("ETag: '.dechex($unique).'-'.dechex($size).'-'.dechex($mtime).'");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue