From cd4cb18cccdd092b4cdbba7769eca803d26830b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Padez?= Date: Sat, 29 Aug 2026 23:55:19 +0100 Subject: [PATCH] a year on assets, now that their URLs change Seven days was correct while the URLs were bare: a stable name with a long life means somebody running last week's script against this week's markup. The site's layout now stamps every asset URL with the build's id, so a build that changes a file changes its URL, and the HTML carrying those URLs is no-cache and revalidated every visit. The two cannot disagree, which is what earns `immutable` and a year. Co-Authored-By: Claude Opus 5 (1M context) --- api/static-site.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/api/static-site.ts b/api/static-site.ts index 55403d9..b8b09fa 100644 --- a/api/static-site.ts +++ b/api/static-site.ts @@ -245,13 +245,15 @@ const NGINX_CONF = `server { add_header Cache-Control "public, immutable"; } - # Everything a build produces. Seven days and no more: these names are stable across builds and the - # HTML that references them is revalidated every time, so a longer life means a visitor running last - # week's stylesheet against this week's markup. Fingerprinted filenames are what would earn a year - # here, and the build does not write them. + # Everything a build produces. A year, and immutable — earned, not assumed: every asset the layout + # links carries `?v=`, so a build that changes a file changes its URL, and the HTML that + # carries the new URLs is `no-cache` and revalidated on every visit. The two cannot disagree. + # + # This was seven days for as long as the URLs were bare, which was correct then: a stable name with a + # long life means somebody running last week's script against this week's markup. location ~* \\.(css|js|webp|png|jpg|jpeg|gif|svg|ico|mp4)$ { - expires 7d; - add_header Cache-Control "public"; + expires 1y; + add_header Cache-Control "public, immutable"; } location / {