Storage and reuse are separate
An HTTP cache stores responses and can reuse them for later matching requests. Permission to store a response is different from permission to reuse it without contacting the origin. Read cache directives according to those separate decisions.
The no-store directive tells a cache not to store the response. Despite its name, no-cache does not categorically prohibit storage; it requires validation before reuse. Treating the two as synonyms can produce the wrong behavior for either performance or sensitive content. A directive is also not retroactive deletion of every copy that already exists elsewhere.
Validate a stale response
For a response with max-age=60, a cache computes freshness using its age and the applicable policy. Expiry does not mean that the underlying data changed at that instant. It means that unvalidated reuse is no longer justified by that freshness lifetime.
A stored ETag can be sent in If-None-Match. If the representation is unchanged, a 304 response allows reuse of the stored body instead of transmitting it again. The cache must retain the representation to which that validation applies; a 304 is not a replacement body.
Scope and cache keys
A browser cache and a shared CDN cache have different sharing boundaries. A response suitable for one user is not automatically suitable for reuse across users. Inspect private/public directives and authorization handling before caching personalized content.
Vary describes request-header fields that affect representation selection. For example, an Accept-Encoding variation can distinguish compressed representations. The URL alone may therefore be an incomplete cache key. Incorrect keys can return the wrong language or user-specific data even when the cache is functioning exactly as configured.
Check updates without guessing
When an update is invisible, inspect response headers and the actual request path. Browser storage, a service worker, a CDN and an application cache may coexist. Clearing one layer does not establish that the remaining layers fetched a new representation.
Disabling caching for all dynamic content can also create avoidable traffic and computation. Design around acceptable staleness, sharing boundaries and invalidation behavior. A useful investigation records the observed Age, Cache-Control and validators rather than assuming that a reload always contacted the origin.
Trace freshness for sixty seconds and a 304 response
For a worked example, ignore transit delay and clock error. A response is generated and stored at time zero with Cache-Control: max-age=60 and ETag: "v7". At time 50, the same cache key can reuse the fresh response if the other reuse conditions hold. At time 70 it is ordinarily stale. The cache can validate with If-None-Match: "v7"; a 304 Not Modified response updates applicable metadata and permits use of the stored representation. A 304 does not mean that the user should receive an empty page. Real age calculations also account for Date, Age and transmission timing.
If the URL serves English and Japanese, matching solely on the URL can select the wrong representation. Vary: Accept-Language makes the relevant request-header value part of the matching conditions. Whether personalized content can enter a shared cache is another decision. The no-cache directive permits storage but requires validation before reuse, while no-store restricts storage itself. Keep freshness, validation, representation matching and storage permission separate. Then evaluate both request and response directives rather than replacing these decisions with a single cache-enabled flag.
| Time or response | Ordinary decision |
|---|---|
| 0 s | Store with max-age=60 and ETag=v7 |
| 50 s | Fresh reuse if other conditions hold |
| 70 s | Stale; conditional validation is possible |
| 304 response | Update applicable metadata and use stored body |
Include age when reasoning about freshness
Suppose a response from a shared cache carries max-age=60 and Age=40, with additional transfer time ignored for the calculation. It has roughly twenty seconds of freshness left, not a fresh sixty-second allowance starting at the next browser. After another twenty-five seconds it is ordinarily stale. Real current-age calculation also uses dates and timing information, so subtracting one header mechanically is not a universal implementation algorithm. Clock differences and several cache layers can complicate observations. Fresh means eligible for reuse without validation under the relevant rules; it is not a live observation that the underlying database value remains unchanged at this instant.
Check the sharing boundary for personalized responses
A user-specific dashboard must not become publicly reusable merely because two users request the same URL. Check storage rules, authorization-related restrictions, private directives, and the application or CDN cache key. Vary specifies request-header matching; it does not perform arbitrary resource authorization. Nor should an application assume that the presence of a cookie makes every implementation refuse storage automatically. Use synthetic users and harmless data to test whether one user’s response can reach another. The right question is who may reuse which representation under which conditions. A high hit rate is a performance observation and does not establish that this sharing decision is correct.
Test an update against an already stored response
Start an invalidation test with the old representation genuinely stored, update the source, and observe which cache serves subsequent requests. Content-addressed static assets and an API that changes under the same URL use different update strategies. A page reload, browser storage, CDN invalidation, and service-worker replacement are distinct operations. Responses such as redirects or errors can also be cacheable under applicable rules, so checking only successful HTML misses some stale behavior. Before disabling everything, preserve the request and response headers needed to reproduce the result. Classify the discrepancy as storage, freshness, validation, or matching, and change the narrow mechanism that actually disagreed with the intended policy.
Exercise: match two languages and two users
The URL /products returns Japanese or English product information shared by all users. Responses contain Cache-Control: public, max-age=60 and Vary: Accept-Language. A Japanese request from user A is stored at time zero. At time ten, user B requests English. May a cache return the Japanese body because the URL matches and the response is fresh? No: the stored response's Vary matching condition is not satisfied. Obtain the English representation instead.
At time twenty B requests Japanese. In this exercise there is no authorization restriction or other reuse constraint, so the common Japanese representation stored for A can be reused when all applicable conditions hold. A different user does not automatically prohibit sharing public content. Conversely, matching language does not authorize sharing personal data. Give separate answers for representation matching and storage permission rather than answering only whether caching is enabled.
Change the endpoint to /my-orders, put A's order identifiers in the body and use Cache-Control: private, max-age=60. A shared cache cannot store this response. Adding a language Vary field does not widen the private sharing boundary. A user's private cache still needs to associate the right body with the intended user and representation. The presence of a cookie or ETag alone is not evidence that authorization or user separation has been implemented. The table deliberately distinguishes these cases so a correct language key cannot conceal the wrong audience.
For the final task, only the English product representation changes. Can the cache use a Japanese representation's ETag as interchangeable evidence about English? The model answer is to associate the conditional request with the selected English representation and its validator. Preserve which representation the validator describes. Receiving a 304 is not permission to replace arbitrary bodies across languages or users. In a harmless implementation exercise, record each request header, response policy and selected body together. That record lets you identify a matching error separately from a storage-policy error, even if both produce a high cache hit rate.
| Request | Shared-cache decision |
|---|---|
| B, English /products | Stored Japanese response fails Vary matching |
| B, Japanese /products | Common response reusable if other conditions hold |
| A /my-orders with private | Do not store in a shared cache |
| B /my-orders | Do not reuse A's personal order body |