(Personally, this answer is totally a mess :rage::rage::rage:, I may rewrite it some day…:disappointed_relieved::sob:)
Cache-Control (Response Header Mainly)
- 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.
- What may be stored by caches
no-store
: Do not store any part of this request (or response). Designed for sensitive information requirements.
- The expiration mechanism
max-age
: Imply the response is cacheable unless other more restrictive cache directive is also present.max-age
directive overridesExpires
header.s-maxage
: For shared cache (CDN), the maximum age specified by this directive will overridemax-age
directive andExpires
header. If this cache becomes stale, must revalidate it when respond to a subsequent request. Ifprivate
, this will be ignored.
- Cache revalidation and reload controls
must-revalidate
: Revalidate the resource on any subsequent request every time and not serve stale content.proxy-revalidate
: Similar tomust-revalidate
, except that it does not apply to non-shared user agent caches.
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.- Cache control extensions: Unrecognized directives will be ignored.
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.