Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Cacheable

A cacheable response is an HTTP response that can be cached, that is stored to be retrieved and used later, saving a new request to the server. Not all HTTP responses can be cached, there are the following constraints for an HTTP response to be cached:

  • The method used in the request is itself cacheable, that is either a GET, a HEAD, or an OPTIONS method. A response to a POST method can also be cached if freshness is indicated, but this is rarely implemented. Other methods, like PUT or DELETE are not cacheable and their result cannot be.
  • The status code of the response is known by the application caching, and it is considered cacheable. The following status code are cacheable: 200, 203, 204, 206, 300, 301, 404, 405, 410, 414, and 501.
  • There is no specific headers in the response, like Cache-Control, that prevents caching.

Note that some non-cacheable requests/responses to a specific URI may invalidate previously cached responses on the same URI. For example, a PUT to pageX.html will invalidate all cached GET or HEAD requests to the same URI.

When both, the method of the request and the status of the response, are cacheable, the response to the request can be cached:

GET /pageX.html HTTP/1.1
(…) 

200 OK
(…)

A PUT request cannot be be cached. Moreover, it invalidates cached data for request to the same URI done via HEAD or GET:

PUT /pageX.html HTTP/1.1
(…)

200 OK
(…)

A specific Cache-Control header in the response can prevent caching:

GET /pageX.html HTTP/1.1
(…)

200 OK
Cache-Control: no-cache
(…)

Learn more

General knowledge

  • Definition of cacheable in the HTTP specification.

Technical knowledge

Document Tags and Contributors

 Contributors to this page: fscholz, teoli
 Last updated by: fscholz,