HEL-580: version asset URLs to bust stale browser caches
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
@@ -6,6 +6,14 @@ function e(string $v): string
|
||||
return htmlspecialchars($v, ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
|
||||
/** 静态资源引用统一加版本号(文件 mtime):文件一变 URL 即变,老用户浏览器无需清缓存 */
|
||||
function assetUrl(string $path): string
|
||||
{
|
||||
$file = __DIR__ . '/../public/' . ltrim($path, '/');
|
||||
$v = is_file($file) ? filemtime($file) : 0;
|
||||
return $path . '?v=' . $v;
|
||||
}
|
||||
|
||||
function now(): string
|
||||
{
|
||||
return date('Y-m-d H:i:s');
|
||||
|
||||
Reference in New Issue
Block a user