Skip to content

.tip

· one of the small things

Four Cache-Control values cover almost every case

Use no-store for anything personal or secret, so it's never written to disk. Use no-cache for pages that have to be revalidated every time but can answer 304. Use public, max-age=31536000, immutable for hashed assets that never change at that URL. And use s-maxage for the CDN when the browser should keep it for less time than the edge.

Cache-Control: public, max-age=60, s-maxage=3600, stale-while-revalidate=86400

stale-while-revalidate is what makes a site feel instant: it serves the old copy now and fetches the new one in the background.

httpcaching