HTTP caching lets a stored response satisfy a later request when the applicable rules permit reuse. The Cache-Control response header expresses directives for caches. A browser cache is a private cache, while an intermediary serving several users is a shared cache. The distinction matters because a response suitable for one user is not automatically suitable for storage in a shared cache.
Freshness and storage
The max-age directive sets a freshness lifetime in seconds. A fresh stored response can often be reused without contacting the origin. Its age includes time already spent in caches, so the freshness window is not simply restarted at every hop. The s-maxage directive applies to shared caches and overrides max-age or Expires there.
The no-cache directive permits storage but requires successful validation before reuse, subject to the rules of HTTP caching. It does not mean that the body must always be downloaded again. By contrast, no-store tells a cache not to store the response. Neither directive should be treated as an access-control mechanism: authorization and protection of sensitive content need their own design.
The private directive prevents shared caches from storing a response, while allowing private caches to store it under the remaining rules. The public directive can explicitly allow shared caching in circumstances where it would otherwise be restricted. Responses personalized by identity, request headers, or cookies require careful consideration before shared storage is enabled.
Validation with ETag
An ETag is an opaque validator chosen by the server for a representation. When a cached response needs validation, a client can send its stored tag in If-None-Match. For a conditional GET, if the selected representation matches under the comparison rules, the server can return 304 Not Modified. The cache then updates relevant metadata and reuses its stored body.
Validation still involves a network exchange, even when it avoids transferring the representation again. A fresh cache hit can avoid that exchange. Strong and weak entity tags have different comparison properties; a weak tag indicates semantic equivalence rather than byte-for-byte identity. Applications should not assume that every ETag is a file hash or that tags from unrelated resources are comparable.
Versioned assets
For files whose URLs change whenever their contents change, a long freshness lifetime can be paired with immutable. An example is Cache-Control: public, max-age=31536000, immutable for a fingerprinted stylesheet. The immutable extension tells clients that the representation will not change during its freshness lifetime. This can avoid unnecessary conditional requests while the response remains fresh.
This pattern depends on actually preserving the contents at the old URL. Publishing different bytes under the same long-lived URL can leave visitors using an earlier version. HTML often needs a different policy because it points to the current asset URLs. Using no-cache for HTML allows storage with validation, while versioned assets can remain fresh for much longer.
Check the selected representation
Inspect response headers and conditional requests together. Vary identifies request header fields that affect representation selection and therefore cache matching. Verify compressed variants, authenticated responses, and error responses separately. A correct policy describes both how long a response may be reused and which requests it can satisfy; a large lifetime alone does not establish either correctness or useful cache reuse.