diff --git a/tools/dev-deploy/Caddyfile.dev b/tools/dev-deploy/Caddyfile.dev index eb949a1..b882736 100644 --- a/tools/dev-deploy/Caddyfile.dev +++ b/tools/dev-deploy/Caddyfile.dev @@ -13,6 +13,23 @@ @frontend host www.galaxy.lan handle @frontend { root * /srv/galaxy-ui + + # SvelteKit emits hash-named JS/CSS chunks under + # `_app/immutable/`; the file name changes whenever the + # content changes, so the browser can cache them forever. + # Without an explicit Cache-Control, Caddy falls back to + # heuristic caching that revalidates on every reload — + # measurably slow on Safari + the long-lived dev stack + # when the cache is warm. Everything else (index.html + # fallback, env.js, version.json, core.wasm, + # wasm_exec.js, favicon.svg) must revalidate so a fresh + # deploy lands without the user having to clear the + # cache by hand. + @immutable path /_app/immutable/* + header @immutable Cache-Control "public, max-age=31536000, immutable" + @dynamic not path /_app/immutable/* + header @dynamic Cache-Control "no-cache, must-revalidate" + try_files {path} /index.html file_server encode zstd gzip diff --git a/tools/dev-deploy/Caddyfile.prod b/tools/dev-deploy/Caddyfile.prod index 5784c28..45895f1 100644 --- a/tools/dev-deploy/Caddyfile.prod +++ b/tools/dev-deploy/Caddyfile.prod @@ -5,6 +5,16 @@ www.galaxy.com { root * /srv/galaxy-ui + + # Mirrors the cache policy `Caddyfile.dev` documents in detail: + # SvelteKit's hash-named `_app/immutable/*` is safe to cache + # forever; everything else must revalidate so a deploy reaches + # the browser without a manual cache clear. + @immutable path /_app/immutable/* + header @immutable Cache-Control "public, max-age=31536000, immutable" + @dynamic not path /_app/immutable/* + header @dynamic Cache-Control "no-cache, must-revalidate" + try_files {path} /index.html file_server encode zstd gzip