DEV Community has published a reference guide on HTTP caching headers. It says nearly every caching bug comes from a mistake in one of two decisions: freshness (reusing a stored response without asking the origin server) and validation (cheaply refreshing a stale copy). Because browsers, proxies, CDNs and service workers enforce the rules, a wrong header often passes staging and fails in production.
The guide separates directives people often confuse. According to the article, no-cache means store the response but revalidate before each reuse, while no-store means do not keep it at all. private lets the browser store a response but blocks shared caches such as CDNs. It also covers stale-while-revalidate and stale-if-error, which let a cache serve an old copy during a refresh or an outage, and which can hide origin failures.
For deployment, the guide recommends opposite policies for two kinds of file. Hashed assets, whose file name changes when the content changes, can be cached for a year with public, max-age=31536000 and immutable. HTML should be revalidated often, using no-cache with a strong ETag or a short shared lifetime, because long-lived HTML can point to bundles a new release has deleted. It advises uploading new assets before the HTML that references them and keeping the previous release for at least one cache lifetime.
The article also warns about Vary, the header that lists which request headers change a response. A missing Vary: Accept-Encoding can serve the wrong compression to a client, while Vary: User-Agent or Vary: Cookie can wreck the cache hit ratio. It notes that Set-Cookie does not stop a shared cache storing a response, and that purging a CDN does not clear browser caches. Versioned URLs are described as the only invalidation method that works across every cache. For anything authenticated or personal, it advises no-store, plus a CDN rule that bypasses those paths.
Why it matters
Caching mistakes can cost you in two directions. Too little caching adds round trips and load on your server. Too much can show visitors old pages, broken scripts after a deploy, or, in the worst case, another user's private data. The guide says such errors often do not appear in testing.
Most site owners rely on a CDN or hosting layer that sets some of these headers for them. Knowing what each directive does helps you check what that layer is actually sending, and decide which pages and files can be cached for long and which must never be stored.
Source: DEV Community. This brief summarises their reporting; read the original for the full detail.