js, css 캐시 문제로 printJS, printCSS 함수를 이용하도록 변경
This commit is contained in:
@@ -88,4 +88,41 @@ class WebUtil
|
||||
|
||||
return $decoded;
|
||||
}
|
||||
|
||||
public function printJS(string $path){
|
||||
//async, defer 옵션 고려
|
||||
$upath = \phpUri::parse($path);
|
||||
$path = $upath->join();
|
||||
if(!$upath->scheme && file_exists($upath->path)){
|
||||
$mtime = filemtime($upath->path);
|
||||
if($upath->query){
|
||||
$tail = '&'.$mtime;
|
||||
}
|
||||
else{
|
||||
$tail = '?'.$mtime;
|
||||
}
|
||||
}
|
||||
else{
|
||||
$tail = '';
|
||||
}
|
||||
return "<script src='{$path}{$tail}'></script>\n";
|
||||
}
|
||||
|
||||
public function printCSS(string $path){
|
||||
$upath = \phpUri::parse($path);
|
||||
$path = $upath->join();
|
||||
if(!$upath->scheme && file_exists($upath->path)){
|
||||
$mtime = filemtime($upath->path);
|
||||
if($upath->query){
|
||||
$tail = '&'.$mtime;
|
||||
}
|
||||
else{
|
||||
$tail = '?'.$mtime;
|
||||
}
|
||||
}
|
||||
else{
|
||||
$tail = '';
|
||||
}
|
||||
return "<link rel='stylesheet' type='text/css' href='{$path}{$tail}' />\n";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user