HEL-580: version asset URLs to bust stale browser caches

Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
美术师
2026-09-18 19:52:34 +08:00
co-authored by multica-agent
parent b4fdc41256
commit 0e2e5f02de
3 changed files with 12 additions and 4 deletions
+8
View File
@@ -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');