Trefferwurf-Knopf dezent als .btn, Cache-Buster aus Dateizeit statt fester Version

This commit is contained in:
torsten 2026-11-22 19:16:38 +01:00
parent f9126675b2
commit 38ad53254c
3 changed files with 19 additions and 27 deletions

View file

@ -88,12 +88,19 @@ function url(string $path = '/'): string
return $base . $path;
}
/** Cache-Buster: bei Änderungen an app.css/app.js erhöhen. */
/** Notnagel-Cache-Buster, falls eine Datei fehlt (normal: Änderungszeit). */
const WS_ASSET_VERSION = '5';
/**
* Asset-URL mit Cache-Buster. Die Version ist die Änderungszeit der Datei –
* dadurch kommen neue app.css/app.js ohne manuelles Hochzählen an.
*/
function asset(string $path): string
{
return url('/assets/' . ltrim($path, '/')) . '?v=' . WS_ASSET_VERSION;
$relative = ltrim($path, '/');
$file = WS_ROOT . '/assets/' . $relative;
$version = is_file($file) ? (string) filemtime($file) : WS_ASSET_VERSION;
return url('/assets/' . $relative) . '?v=' . $version;
}
function redirect(string $path, int $status = 303): never