Skip to content
App
Markdown

Caching

Honest by default — strong ETags everywhere, immutable only where the file name proves it.

The caching policy fits in three rules, and you can verify every one of them in the response headers of your own site.

1. Every asset revalidates by content

Every asset served from a release carries its sha256 as a strong ETag and cache-control: public, max-age=0, must-revalidate. Updates are visible immediately after a deploy; repeat loads are 304s that move no bytes. There is no "it might take 10 minutes to update" and no cache to purge.

2. Hash-named files are immutable

Files under the output directories bundlers own — Astro's _astro/, Vite's assets/, Next.js's _next/static/, SvelteKit's _app/immutable/ and Nuxt's _nuxt/ — with hash-stamped filenames get cache-control: public, max-age=31536000, immutable: the content hash is in the name, so the browser never needs to ask again. A new build writes new names; the old names keep serving for as long as their release is retained.

That is the whole heuristic. Nothing else is guessed immutable, ever — a logo.png you might overwrite tomorrow revalidates like everything else.

3. Compression is negotiated

Responses are compressed with brotli, zstd or gzip according to the request's Accept-Encoding, with vary: accept-encoding set. Formats that are already compressed (images, video, archives) and tiny bodies are left alone. Compressed variants are cached on the host, so compression is paid once per file, not once per request.

What this means for your build

Any bundler's default output does the right thing automatically: HTML revalidates, hashed JS/CSS is immutable. If you hand-name files, remember that only hash-stamped names in the bundler directories get the year — name things app.css and they will revalidate on every load, correctly.

Content your server code reads from the data plane can be cached beside the app as well, kept fresh by the data plane's change feed rather than by a TTL: see cached entity reads.

Type to search. ↑↓ to move, Enter to open, Esc to close.