Scrivio Interview library
ConceptFoundations7 min read · updated 13 November 2026

HTTP caching is controlled mainly by the Cache-Control response header. Browsers, proxies and CDNs read it to decide whether they may store a response, for how long, and when they must check with the server.

Explain no-store, no-cache, max-age=0, must-revalidate, private and public, and say which you would send for a login page, a versioned product image and a user's order list.

no-store forbids any cache from keeping the response, while no-cache lets caches keep it but forces a check with the server before every use; max-age=0 makes a response stale immediately, and must-revalidate forbids serving a stale copy without a successful check. private limits storage to the user's own browser, and public allows shared caches such as CDNs to store it. For a login page we send no-store, for a versioned product image public, max-age=31536000, immutable, and for a user's order list private, no-cache with an ETag.

Background to this question

Many web performance problems and privacy incidents trace back to one header, Cache-Control, whose directives have names that sound alike: no-cache and no-store mean very different things. Mixing them up either makes a site slow, by forbidding useful caching, or makes it leak data, by letting a shared cache keep personal pages. In this answer, we will recap who the caches are, go through each directive and what a cache does with it, choose headers for the three example responses, and finish with the older Expires and Pragma headers.

1A Quick Recap: Fresh, Stale and Who Caches

There are two kinds of HTTP cache. A private cache belongs to one user, in practice the browser's cache. A shared cache serves many users: a CDN edge server, a corporate proxy or an API gateway cache.

A stored response is fresh while its age is below its freshness lifetime, which usually comes from max-age. A fresh response can be used without asking the server. Once it is older, it becomes stale, and the cache should revalidate it: send a conditional request, such as If-None-Match with the stored ETag (a fingerprint of the content), and the server answers either 304 Not Modified, meaning the stored copy is still good, or 200 with a new body. A 304 has no body, so revalidation is cheap even when it happens on every request.

2No-store Versus no-cache

no-store is the strict one. It tells every cache, private and shared, not to keep the response at all. Each use means a full request and a full response from the server. We use it for content that must never sit on a disk or in a shared cache, such as pages showing secrets or a bank balance.

no-cache sounds similar but means the opposite of what its name suggests: caches may store the response, but must revalidate it with the server before each use. So the browser keeps a copy and sends If-None-Match every time; if nothing changed, it gets a tiny 304 and shows the stored copy. The reason this is useful is that we always get the current version, but we only download the body when it actually changed.

YAML
# First request for the order list
GET /orders -> 200, ETag: "v42", Cache-Control: private, no-cache (body: 18 KB)
# Next visit: the browser has a copy but must check first
GET /orders
If-None-Match: "v42" -> 304 Not Modified (body: 0 bytes)
# After a new order is placed
GET /orders
If-None-Match: "v42" -> 200, ETag: "v43" (body: 19 KB)

Notice that with no-store the second and third requests would both download the full body, because nothing was kept to revalidate.

3Max-age=0, must-revalidate, and s-maxage

max-age=N says the response is fresh for N seconds. max-age=0 makes it stale the moment it is stored. That looks the same as no-cache, and in normal operation browsers treat them almost alike, but there is a difference. HTTP allows caches in some situations, for example when the origin cannot be reached, to serve a stale response with a warning. no-cache never allows using the stored copy without revalidation, while max-age=0 on its own leaves that door open.

must-revalidate closes it. It says that once the response is stale, the cache must not use it without a successful revalidation; if the origin is down, the cache returns an error, typically 504, instead of the stale copy. So max-age=0, must-revalidate behaves like no-cache, and max-age=600, must-revalidate means fresh for ten minutes, then strictly checked.

s-maxage=N works like max-age but applies only to shared caches, and overrides max-age for them. This lets us say, for example, max-age=60, s-maxage=600: the browser rechecks after a minute, while the CDN, which we can purge, keeps the page for ten minutes.

4Private Versus public

private says only the user's browser may store the response; a CDN or proxy must pass it through without keeping it. We use it for anything specific to one user.

public says shared caches may store the response even where they normally would not. The main case is a request carrying an Authorization header: by default a shared cache must not reuse such a response for other requests, because it was probably personal, and public says it is safe to share. For an ordinary response with max-age, public adds little but does no harm.

What each directive tells a cache
DirectiveMay store?May use without asking server?
no-storeNo, no cache at allNot applicable
no-cacheYesNo, revalidate every time
max-age=0YesNo in normal use; stale use possible in some cases
must-revalidateYesWhile fresh yes; when stale only after a check
privateBrowser only, not CDNs or proxiesDepends on max-age or no-cache
publicShared caches too, even with AuthorizationDepends on max-age or s-maxage
s-maxage=NShared cachesShared caches for N seconds

5Choosing Headers for the Three Responses

The login page and anything else carrying secrets, such as a password reset form with a token, gets no-store. We do not want it in a shared computer's disk cache, let alone on a CDN, and its small HTML costs little to send again.

A product image with a versioned URL, such as /img/shoe-3f9a1c.webp where the hash changes whenever the file changes, gets public, max-age=31536000, immutable. That is one year, the conventional maximum. The reason it is safe is that the content at that URL never changes; a new image gets a new URL. immutable tells browsers not to revalidate even when the user presses reload, which saves a request per image.

A user's order list gets private, no-cache with an ETag, as the earlier example showed. private keeps it off shared caches, and no-cache means the user always sees new orders immediately, while an unchanged list costs only a 304.

Text
Login page: Cache-Control: no-store
Versioned image: Cache-Control: public, max-age=31536000, immutable
Order list: Cache-Control: private, no-cache
ETag: "orders-1042-v43"

6Expires and Pragma: The Older Mechanisms

HTTP/1.0 used the Expires header, an absolute date after which the response is stale, and Pragma: no-cache. Expires depends on server and client clocks agreeing, which is why the relative max-age replaced it, and Pragma was only ever defined for requests and is now deprecated. When Cache-Control is present it takes precedence, so these headers matter only for very old clients.

7Follow-up questions

What does a browser do with a response that has no caching headers at all?

It may apply heuristic freshness. HTTP allows a cache to guess a freshness lifetime for responses with cacheable status codes such as 200 when there is no explicit expiry, and the usual guess is a fraction, commonly 10 percent, of the time since the Last-Modified date. So a file last modified ten days ago might be reused for about a day without asking the server. The exact behaviour differs between browsers, so check yours, but the lesson is that a missing header does not mean do not cache; we should always send an explicit Cache-Control.

Is no-cache enough for sensitive data?

No. no-cache still allows the response to be stored, on disk in the browser and, unless private is also set, in shared caches. It only forces a check before use. For sensitive data the right directive is no-store.

8Conclusion

In this answer, we saw that no-store forbids storing at all, while no-cache allows storing but demands revalidation before each use, which with an ETag costs only a 304. max-age=0 makes a response stale at once, and must-revalidate forbids serving it stale without a successful check. private keeps a response in the browser only, public lets shared caches store it even for authorised requests, and s-maxage sets a separate lifetime for shared caches. A login page gets no-store, a versioned image public, max-age=31536000, immutable, and an order list private, no-cache with an ETag. Expires and Pragma are older mechanisms that Cache-Control overrides.

What to say in the interviewAbout 90 seconds aloud

Open with

The two that people mix up are no-store and no-cache. no-store means no cache may keep the response at all. no-cache means caches may keep it but must revalidate with the server before each use, so with an ETag an unchanged response costs only a 304 with no body. max-age is the freshness lifetime in seconds, so max-age=0 makes it stale immediately, and must-revalidate says a stale copy must never be served without a successful revalidation, even if the origin is down. s-maxage does the same as max-age but only for shared caches like a CDN, and overrides max-age there. private means only the user's browser may store it, not CDNs or proxies, and public means shared caches may store it, even in cases they normally would not, such as a request with an Authorization header.

Then, if they want more

For a login page I would send no-store, because it carries secrets and is cheap to render. For a product image with a content hash in its URL, public, max-age=31536000, immutable, because that URL never changes.

For a user's order list, private, no-cache with an ETag, so it never sits on a shared cache and the user always sees new orders, but unchanged lists cost a 304. Expires and Pragma are older; when Cache-Control is present, it wins.

About this answer

Last updated
13 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the official documentation for the version you use. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Explain no-store, no-cache, max-age=0, must-revalidate, private and public, and say...": https://scrivio-interview-library.netlify.app/architecture/caching-strategies/62b5d8d803/