AIStacker
WebBest Practice Guide8 min read

no-store vs no-cache vs max-age for HTML, APIs, and Versioned Assets

A practical caching guide for choosing the right Cache-Control strategy for authenticated HTML, revalidating APIs, and long-lived static assets before copied directives start conflicting.

In this guide
3
Tools used in this guide
2
Related topics
6
Guide overview

Cache-Control bugs rarely start as obvious syntax mistakes. More often, they start when a team copies one directive from an article about API freshness, another from a CDN checklist, and a third from a static asset recipe, then ships all three together on the same response. The header is valid, but the intent is muddy.

A better approach is to pick the cache strategy from the response type first. Authenticated HTML, revalidating API JSON, and versioned assets should not all inherit the same policy. Once you decide which class of response you are looking at, the header becomes much easier to reason about and much easier to review.

01

Use no-store when retaining a reusable copy is the real risk

#

Responses tied to one user, one private session, or one sensitive dashboard often need the strongest boundary: do not keep a reusable copy. That is where no-store makes sense. It is less about freshness and more about preventing browsers or intermediaries from retaining a response that should not hang around.

This is why no-store is a better fit for personal account HTML or highly sensitive API responses than for normal public pages. If the main risk is reuse itself, not merely staleness, start there instead of layering several weaker directives together.

Tools for this section

02

Use no-cache when reuse is acceptable only after revalidation

#

A lot of teams read no-cache as if it means do not cache. In practice, it is closer to do not reuse without checking first. That distinction matters for API responses and HTML that can be stored briefly but should still confirm freshness before the next use.

This strategy becomes much clearer when validators such as ETag or Last-Modified are present. In that setup, the cached copy is not automatically thrown away, but it does need to prove that it is still current before the browser or intermediary can reuse it confidently.

Tools for this section

03

Use long max-age and immutable for versioned assets only

#

Long-lived caching with max-age and immutable is ideal for files whose URLs change whenever the content changes. That usually means hashed JS bundles, CSS files, fonts, or images with content-based versioning. In that context, you want aggressive reuse because the URL itself already encodes the update boundary.

What breaks teams is taking that exact recipe and applying it to HTML or API payloads. Those responses often live at stable URLs and need revalidation or even no-store semantics. The header is not wrong by itself, but it becomes wrong once you move it to the wrong response class.