From 04a17899fc798c8db6f40df7dee13721aaa649c0 Mon Sep 17 00:00:00 2001 From: Ryan Malloy Date: Tue, 24 Feb 2026 11:16:58 -0700 Subject: [PATCH] Fix cache headers: immutable for hashed assets, revalidate for HTML The blanket max-age=3600 caused stale HTML pages after redeployment. Now _astro/* gets immutable (content-addressed filenames) and HTML pages get no-cache (always revalidate, 304 when unchanged). --- docs/Caddyfile | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/Caddyfile b/docs/Caddyfile index b29ce2a..086c978 100644 --- a/docs/Caddyfile +++ b/docs/Caddyfile @@ -2,6 +2,14 @@ root * /srv file_server encode gzip zstd - header Cache-Control "public, max-age=3600" + + # Hashed assets: cache forever (filename changes on content change) + @hashed path /_astro/* + header @hashed Cache-Control "public, max-age=31536000, immutable" + + # Everything else (HTML pages): always revalidate + @unhashed not path /_astro/* + header @unhashed Cache-Control "no-cache" + try_files {path} {path}/ /404.html }