When a response is not cached, it is usually because the server or client explicitly tells the browser or intermediary to avoid storing it. The most common reasons are cache‑control headers that forbid caching, non‑cacheable HTTP methods or status codes, or dynamic content that changes on each request.
What Determines Cacheability
HTTP caching is governed by a combination of the request method, the response status code, and the presence of specific headers. The RFC 7234 standard defines which combinations are considered cacheable by default and which are not. In practice, the following rules apply:
- GET and HEAD requests are cacheable if the response includes a suitable cache header.
- Responses with status codes 200, 203, 300, 301, 404, 405, 410, 414, 501, and 502 are cacheable unless overridden.
- Responses with status codes 302, 307, 308, 401, 403, 500, 501, 503, and others are considered non‑cacheable by default.
- Any request method other than GET or HEAD (e.g., POST, PUT, DELETE) is treated as non‑cacheable unless the server explicitly marks the response as cacheable.
Headers That Block Caching
Even if a request method and status code would normally allow caching, certain headers can prevent it. The most common ones are:
Cache-Control: no-store– Instructs all caches to store nothing.Cache-Control: no-cache– Requires revalidation before reuse but does not forbid storage.Cache-Control: private– Allows storage only in a private cache (e.g., a browser), not shared caches.Pragma: no-cache– Legacy header used by older HTTP/1.0 clients.Expires: 0or a past date – Marks the response as immediately stale.- Headers that include a
Set-Cookiedirective can also trigger private caching or prevent caching in shared caches.
Why Some Responses Are Intentionally Uncacheable
Web developers often choose to disable caching for specific reasons:
- Dynamic content – Pages that change with each user or time stamp (e.g., dashboards, shopping carts) should not be cached globally.
- Security – Sensitive data such as authentication tokens, personal information, or financial details must not be stored in shared caches.
- Compliance – Regulations like GDPR or HIPAA require that personal data is not cached in a way that could be accessed by unintended parties.
- Performance tuning – In some cases, developers cache only parts of a page (e.g., using partial responses) and keep the full response uncacheable to reduce load times.
Inspecting Cache Behavior
To determine why a particular response is not cached, use the following steps:
- Open the browser’s developer tools (usually F12 or Ctrl+Shift+I).
- Navigate to the Network tab and reload the page.
- Select the request in question and review the Headers section.
- Look for
Cache-Control,Expires,Pragma, andSet-Cookieheaders. - Check the Response tab for status code and method.
Most modern browsers will also display a Cache column indicating whether the response was served from cache, bypassed, or stored for future use.
Common Pitfalls and Misconceptions
Even when the server sends the correct headers, caching can still fail due to:
- Mixed content – If a page is served over HTTPS but includes HTTP resources, some browsers may refuse to cache the mixed content.
- Proxy misconfiguration – Shared proxies or CDNs can override or strip headers, unintentionally disabling caching.
- Cache key variations – Query strings, cookies, or Accept‑Encoding headers can create distinct cache entries, causing the same resource to appear uncached.
- Inconsistent ETag values – If an ETag changes on every request, browsers will treat the response as stale and revalidate each time.
How to Enable Caching When Appropriate
When you want a response to be cached, configure the following:
- Set
Cache-Control: public, max-age=86400for static assets that can be shared. - Use
ETagorLast-Modifiedheaders to allow conditional requests. - For dynamic content that changes infrequently, consider
Cache-Control: private, max-age=300to store it only in the user’s browser. - Avoid sending
Set-Cookiewith resources that should be cached globally.
Frequently Asked Questions
What is the difference between no-store and no-cache?
no-store tells all caches to keep nothing, while no-cache requires the cache to revalidate the resource before reuse but still allows it to be stored. Use no-store for highly sensitive data.
Can I force a browser to cache a POST response?
By default, POST responses are not cacheable. However, you can add Cache-Control: public, max-age=60 to the response headers to allow caching, though it is uncommon and may lead to unexpected behavior.
Why does my CDN not cache a resource even though I set max-age?
CDNs may have their own rules for private cookies, query strings, or specific file types. Ensure the CDN configuration allows caching for the given URL pattern and that the response headers are not overridden.
How does ETag affect caching?
An ETag is a unique identifier for a specific version of a resource. When the client sends an If-None-Match header with the ETag, the server can respond with 304 Not Modified, saving bandwidth. If the ETag changes on every request, the cache will treat the resource as new each time.
What happens if I set Cache-Control: max-age but also include a Set-Cookie header?
Most browsers treat responses with Set-Cookie as private and will not share them across users, even if max-age is set. The response can still be cached locally, but not in shared caches.