List of Cache-Related HTTP Header Fields?

(Personally, this answer is totally a mess :rage::rage::rage:, I may rewrite it some day…:disappointed_relieved::sob:)

Cache-Control (Response Header Mainly)

  1. What’s cacheable
    • public: This resource is cacheable by clients and shared (proxy) cache. Better for resources that everybody can access.
    • private: Default. Only cacheable by clients and not by shared (proxy) cache. Better for resources intended for only one user.
    • no-cache: Do not use the cache to satisfy subsequent requests without succesful revalidation with the origin server (every time).
      If this directives specify field-names, the cache can be used to satisfy subsequent requests but the specified field-names should be stripped out (like cookies) without succesful revalidation with the origin server.
  2. What may be stored by caches
    • no-store: Do not store any part of this request (or response). Designed for sensitive information requirements.
  3. The expiration mechanism
    • max-age: Imply the response is cacheable unless other more restrictive cache directive is also present. max-age directive overrides Expires header.
    • s-maxage: For shared cache (CDN), the maximum age specified by this directive will override max-age directive and Expires header. If this cache becomes stale, must revalidate it when respond to a subsequent request. If private, this will be ignored.
  4. Cache revalidation and reload controls
    • must-revalidate: Revalidate the resource on any subsequent request every time and not serve stale content.
    • proxy-revalidate: Similar to must-revalidate, except that it does not apply to non-shared user agent caches.
  5. no-transform: The cache or proxy must not change any aspect of the entity-body that is specified by these headers, including the value of the entity-body itself.
  6. Cache control extensions: Unrecognized directives will be ignored.

cache-control

ETag (Entity Tag)

A unique identifier for the requested resource, typically the hash of the resource or the hash of the timestamp the resource was updated. It can be used to validate the entry.

Expires

The date/time after which the response is considered stale. A stale cache entry may not normally be returned by a ache unless it’s first validated with the origin server.

Last-Modified

The date/time at which the origin server believes the resource was last modified.

If-Modified-Since (Request)

If the requested variant has not been modified since the time specified in this field, an entity will not be returned from the server; instead, a 304 response will be returned without any message-body.

If-Unmodified-Since works like If-Modified-Since except the condition is opposite.

If-None-Match (Request)

If any of the entity tags match the entity tag of the requested resource, the server should return 304.

If-Match works like If-None-Match except the condition is opposite.

References

  1. HTTP caching
  2. Header Field Definitions :+1:
  3. Caching in HTTP
  4. Private vs Public in Cache-Control
  5. A Beginner’s Guide to HTTP Cache Headers :+1:
  6. Cache Control Directives Demystified
Comments