When a release appears only after a hard refresh—or when every request reaches your origin—HTTP caching is usually the first place to look. This checklist explains how Cache-Control, ETag, Last-Modified, Vary, browser caches, and CDNs work together, then gives practical workflows for diagnosing stale content and unexpected cache misses before or after a deployment.
Overview
HTTP caching is a negotiation between the response origin, the browser, intermediate proxies, and any CDN in front of the application. A response can be fresh in one cache and absent, expired, or bypassed in another. That is why clearing a browser cache may appear to fix a problem while visitors behind a CDN still receive an older asset.
The most important response header is Cache-Control. It defines whether a response may be stored, how long it can be considered fresh, and whether a cache must check with the origin before using it again.
| Directive | Practical meaning | Typical use |
|---|---|---|
max-age=seconds | A browser may use the response while it remains fresh for the specified period. | Short-lived HTML or API responses; longer periods for versioned assets. |
s-maxage=seconds | Sets a freshness lifetime for shared caches such as CDNs, generally taking precedence over max-age there. | Controlling CDN behavior separately from browser behavior. |
no-cache | The response may be stored, but it must be revalidated before reuse. | HTML or data that can be cached but must be checked for changes. |
no-store | Do not store the response in a cache. | Highly sensitive or strongly personalized responses. |
private | Only a private browser cache may store the response; shared caches should not. | User-specific pages or responses containing session information. |
public | Explicitly permits storage by shared caches when other rules allow it. | Public resources that need predictable CDN caching. |
must-revalidate | Once stale, the cache must revalidate rather than reuse the response under ordinary circumstances. | Content where serving an expired representation is unacceptable. |
immutable | Signals that a fresh response will not change during its freshness lifetime. | Versioned, fingerprinted JavaScript, CSS, and image files. |
ETag and Last-Modified are validators. They do not themselves set a cache lifetime. An ETag identifies a particular representation, while Last-Modified gives a timestamp for the representation. On revalidation, the client can send If-None-Match or If-Modified-Since. If the representation is unchanged, the server can return 304 Not Modified, allowing the cache to reuse its stored body without transferring it again.
ETag is usually the stronger and more precise validator, especially when multiple servers might generate content at different times. Last-Modified can be useful as a fallback, but timestamp precision and clock differences can make it less exact. A deployment should avoid changing validators unpredictably for identical content, because that creates unnecessary transfers and makes behavior harder to inspect.
Vary tells caches which request headers can change the response. For example, Vary: Accept-Encoding separates compressed and uncompressed representations. Content negotiation, language selection, device-specific output, or authorization-related behavior may require additional care. An overly broad Vary value can fragment the cache and reduce hit rates; omitting a relevant value can cause one request variant to be served to another user.
Checklist by scenario
After deploying new JavaScript or CSS
- Use content-hashed filenames such as
app.8f31c.jsso a changed file has a new URL. - Serve successfully fingerprinted static assets with a long freshness period, often paired with
publicandimmutable. - Keep the HTML entry document on a shorter lifetime or require revalidation so it can reference the latest asset filenames.
- Confirm that the CDN can retrieve the new HTML and that its cache purge or revalidation process is understood.
- Test both the new asset URL and the old asset URL. An old URL remaining available may be acceptable, but it should not be referenced by newly served HTML.
When visitors see an old page
- Inspect the document request in browser DevTools and record the status, response headers, Age header if present, cache indicators, and response body.
- Check whether the browser is using a memory or disk cache, a service worker, or a shared CDN response.
- Request the same URL from a private browsing window and from a different network to separate local behavior from edge behavior.
- Review the HTML response's
Cache-Control,ETag,Last-Modified, andAgevalues. - Confirm that the deployment updated the origin being used by the CDN and that DNS or load-balancer routing did not leave some servers on the previous release.
When an API response is stale or never cached
- Decide whether the response is public, user-specific, or dependent on credentials before choosing a cache policy.
- For user-specific data, prefer an explicit private policy or no-store policy as appropriate. Do not make a response public merely to improve performance.
- For public data, define a deliberate freshness window and use ETag or Last-Modified to make revalidation inexpensive.
- Check whether cookies, authorization headers, query strings, or a broad
Varyheader are preventing shared-cache reuse. - Confirm that the CDN is configured to cache the request method and status codes your application expects. Many setups cache GET and HEAD differently from other methods.
When a CDN is not caching
- Inspect the origin response for
private,no-store, or a very shortmax-age. - Look for
Set-Cookie, authorization requirements, cache-bypass rules, and query-string policies. - Check whether the CDN is forwarding every query parameter, creating a different cache key for each URL variant.
- Compare a cache miss and a subsequent request using the CDN's response headers and logs.
- Verify that the configured CDN rule matches the deployed hostname, path, protocol, and environment.
What to double-check
Start with the complete response as seen by a client, not only the application framework's configuration. A reverse proxy, hosting platform, CDN, or server middleware may add, replace, or strip headers. Use a command such as curl -I https://example.com/path to inspect headers without downloading the response body. To test revalidation, first capture the ETag or Last-Modified value, then send a conditional request:
curl -i -H 'If-None-Match: "example-tag"' https://example.com/pathA 304 response indicates that the validator matched; it does not mean the origin sent a new response body. Repeat the test against the origin hostname, CDN hostname, and production hostname when those endpoints are available. Differences identify where a policy is being applied or lost.
Also check cache keys. The scheme, hostname, path, query string, selected headers, and sometimes cookies can determine whether two requests are considered the same. A URL that looks identical in the address bar may produce different cache behavior because of a cookie or authorization header. Conversely, two users may receive the same cached response if the cache key does not include a variation that matters.
For a deployment workflow, treat caching as part of the release design. Publish immutable assets before publishing HTML that references them, keep rollback assets available for the period in which old HTML may still be cached, and define an explicit purge or revalidation step for documents that must change immediately. This complements a secure GitHub Actions deployment for Node.js apps rather than relying on an informal browser refresh.
Common mistakes
- Using
no-cachewhen you meanno-store. No-cache permits storage but requires validation. No-store asks caches not to retain the response. - Long-caching unversioned files. A file named
main.jswith a long lifetime can remain old after a release. Fingerprint the filename or use a reliable invalidation process. - Purging only the browser. A hard refresh does not remove a stale representation held at a CDN or reverse proxy.
- Changing cache policy without checking validators. Removing ETags or producing a new ETag for every response can increase bandwidth and hide deployment problems.
- Ignoring service workers. A service worker can apply its own cache strategy and may serve content independently of ordinary HTTP cache behavior.
- Making personalized data publicly cacheable. Check cookies, authorization, and user-specific fields before allowing shared caching.
- Testing only one location. CDN behavior can vary by point of presence, cache key, and purge timing. Compare multiple requests and environments when the issue is intermittent.
When to revisit
Revisit this checklist before a major release, after changing asset naming or build output, when migrating CDNs or hosting providers, and whenever a deployment introduces a new reverse proxy or service worker. It is also worth reviewing before seasonal traffic planning, because an aggressive cache policy can reduce origin load while an incorrect policy can preserve broken content for longer than expected.
Keep a small cache-policy record with the intended behavior for HTML, static assets, public APIs, authenticated responses, and error pages. After a workflow or platform change, compare that record with real production headers. Test a fresh request, a repeated request, a conditional request, and a request with the relevant cookies or authorization state. If the results differ from the intended policy, fix the rule at the layer that introduced the difference rather than adding repeated purge steps.
For related deployment checks, review the Core Web Vitals optimization checklist and the DNS records troubleshooting reference. Together, these checks help connect cache behavior with the two questions that matter during an incident: which version is being served, and which infrastructure layer is serving it.