From 07f0afde252b6a0a514f6bb5f74607792e2520f6 Mon Sep 17 00:00:00 2001 From: Pontoporeia Date: Thu, 9 Apr 2026 14:07:41 +0200 Subject: [PATCH] cache-bust: add filemtime-based versioning to all CSS and JS assets --- src/App.php | 13 +++++++++++++ templates/admin/footer.php | 2 +- templates/head.php | 6 +++--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/App.php b/src/App.php index b6d6b4e..40a4868 100644 --- a/src/App.php +++ b/src/App.php @@ -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 ──────────────────────────────────────────────────── /** diff --git a/templates/admin/footer.php b/templates/admin/footer.php index cd19b04..1876c30 100644 --- a/templates/admin/footer.php +++ b/templates/admin/footer.php @@ -1,5 +1,5 @@ - + diff --git a/templates/head.php b/templates/head.php index 6fbee50..aeb118b 100644 --- a/templates/head.php +++ b/templates/head.php @@ -64,10 +64,10 @@ - - + + - +