From ef8cc4bf17f68d8901be180a62a4b72c0d4153cd Mon Sep 17 00:00:00 2001 From: simien Date: Sun, 13 Sep 2026 18:37:18 -0400 Subject: [PATCH] perf: cache the versioned assets for a year Every asset carried Cloudflare's default of max-age=0, must-revalidate, so a returning visitor revalidated style.css and generator.js on every load, two round trips before first paint that the ?v= scheme already makes unnecessary: the number moves whenever the file does, and CI fails the build when it does not. The six files that carry a ?v= now get a year-long immutable cache. Pages keep the default, since their names never change, and so does the vendored GIF encoder, which has no ?v=. Co-Authored-By: Claude Fable 5.1 --- _headers | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/_headers b/_headers index 0d75eed..8ae9a5b 100644 --- a/_headers +++ b/_headers @@ -20,3 +20,25 @@ Referrer-Policy: strict-origin-when-cross-origin Permissions-Policy: camera=(), microphone=(), geolocation=(), payment=(), usb=() Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-inline' https://static.cloudflareinsights.com; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob:; worker-src 'self' blob:; connect-src 'self' https://cloudflareinsights.com; font-src 'self'; object-src 'none'; base-uri 'self'; form-action 'self' + +# The files index.html and the document pages request with a ?v= query. +# Their cache is busted by the number, which CI makes sure moves whenever +# the file does, so the copy a browser holds can be trusted for as long as +# a browser will keep it. Without this every asset carried Cloudflare's +# default of max-age=0, and a returning visitor revalidated the stylesheet +# and the generator on every load. Pages stay on the default: their names +# never change, so they have to be checked each time. The vendored GIF +# encoder is left out too; it carries no ?v=, so a swapped file under the +# same name would sit stale for a year. +/style.css + Cache-Control: public, max-age=31536000, immutable +/generator.js + Cache-Control: public, max-age=31536000, immutable +/guide.css + Cache-Control: public, max-age=31536000, immutable +/screenshot.png + Cache-Control: public, max-age=31536000, immutable +/screenshot.webp + Cache-Control: public, max-age=31536000, immutable +/screenshot-800.webp + Cache-Control: public, max-age=31536000, immutable