cache-bust: add filemtime-based versioning to all CSS and JS assets

This commit is contained in:
Pontoporeia
2026-04-09 14:07:41 +02:00
parent 424f79c819
commit 07f0afde25
3 changed files with 17 additions and 4 deletions

View File

@@ -136,6 +136,19 @@ class App
exit;
}
// ── Asset versioning ─────────────────────────────────────────────────────
/**
* Return an asset URL with a filemtime-based cache-busting query string.
* Input is a root-relative URL path (e.g. /assets/css/main.css).
*/
public static function assetV(string $urlPath): string
{
$file = APP_ROOT . '/public' . $urlPath;
$v = file_exists($file) ? filemtime($file) : 0;
return $urlPath . ($v ? '?v=' . $v : '');
}
// ── Template rendering ────────────────────────────────────────────────────
/**