The primary purpose of a cache is to store some of the responses it receives from origin servers. A response is said to be cachable if it can be used to answer a future request. For typical request streams, about 75% of responses are cachable.
A cache decides if a particular response is cachable by looking at different components of the request and response. In particular, it examines the following:
The response status code
The request method
A response validator
These different factors interact in a somewhat complicated
manner. For example, some request methods are uncachable
unless allowed by a
Cache-control directive. Some status
codes are cachable by default, but authentication and
Cache-control take precedence.
Even though a response is cachable, a cache may choose not to store it. Many products include heuristics—or allow the administrator to define rules—that avoid caching certain responses. Some objects are more valuable than others. An object that gets requested frequently (and results in cache hits) is more valuable than an object that is requested only once. Many dynamic responses fall into the latter category. If the cache can identify worthless responses, it saves resources and increases performance by not caching them.
One of the most important factors in determining cachability is the HTTP server response code, or status code. The three-digit status code indicates whether the request ...