2. Overview of Cache Operation
Proper cache operation preserves the semantics of HTTP transfers while reducing the transmission of information already held in the cache. See Section 3 of [HTTP] for general terminology and core concepts of HTTP.
Although caching is an entirely optional (OPTIONAL) feature of HTTP, it can be assumed that reusing cached responses is desirable and, in the absence of requirements or local configuration preventing it, is the default behavior. Therefore, the focus of HTTP cache requirements is on preventing caches from storing non-reusable responses or from reusing stored responses inappropriately, rather than mandating that caches always store and reuse specific responses.
A "cache key (Cache Key)" is the information a cache uses to select a response, consisting of at least the request method (Request Method) and target URI (Target URI) used to retrieve the stored response; the method determines under what circumstances that response may be used to satisfy subsequent requests. However, many HTTP caches in common use today only cache GET responses, thus using only the URI as the cache key.
For request targets that are subject to content negotiation (Content Negotiation), a cache might store multiple responses. The cache distinguishes these responses by incorporating some of the original request's header fields into the cache key as well, using information from the Vary response header field, as described in Section 4.1.
A cache might incorporate additional material into the cache key. For example, a user agent cache might include the identity of the referring site, thereby "double keying (Double Keying)" the cache to avoid certain privacy risks (see Section 7.2).
Most commonly, caches store the successful result of a retrieval request: i.e., a 200 (OK) response to a GET request containing a representation (Representation) of the target resource (see Section 9.3.1 of [HTTP]). However, it is also possible to store redirects, negative results (e.g., 404 (Not Found)), incomplete results (e.g., 206 (Partial Content)), and responses to methods other than GET if the method's definition allows such caching and defines something suitable for use as a cache key.
When a cache cannot contact the origin server (Origin Server) or cannot find a forwarding path for a request, the cache is in a "disconnected (Disconnected)" state. In some circumstances, a disconnected cache can serve stale responses (Stale Responses) (Section 4.2.4).