Cacheable

Eine cacheable Antwort ist eine HTTP-Antwort welche zwischengespeichert werden kann, die aufbewahrt wird um später abgerufen und verwendet werden zu können um dabei dem Server eine neue Anfrage zu ersparen. Nicht all HTTP-Antworten können zwischengespeichert werden. Es gibt folgende Vorraussetzungen damit eine HTTP-Antwort zwischengespeichert wird:

  • The method used in the request is itself cacheable, that is either a GET or a HEAD method. A response to a POST or PATCH request can also be cached if freshness is indicated and the Content-Location header is set, but this is rarely implemented. (For example, Firefox does not support it per https://bugzilla.mozilla.org/show_bug.cgi?id=109553.) Other methods, like PUT or DELETE are not cacheable and their result cannot be cached.
  • 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.
  • Es gibt keine spezifischen Header in der Antwort, wie Cache-Control, welche Zwischenspeicherung verhindert.

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 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
(…)

Erfahre mehr

Allgemeinwissen

  • Definition von cacheable in der HTTP-Spezifikation.

Technisches Wissen

  • Description of common cacheable methods: GET, HEAD
  • Description of common non-cacheable methods: PUT, DELETE, often POST