Cache-Control Headers

CDN’s job is to Cache the content locally. This can be done with the Cache-Control headers.

The headers are:
Cache-Control: Max-Age
The max-age request directive defines, in seconds, the amount of time it takes for a cached copy of a resource to expire. After expiring, a browser must refresh its version of the resource by sending another request to a server.

Cache-Control: No-Cache
The no-cache directive means that a browser may cache a response, but must first submit a validation request to an origin server.

Cache-Control: No-Store
The no-store directive means browsers aren’t allowed to cache a response and must pull it from the server each time it’s requested. This setting is usually used for sensitive data, such as personal banking details.

Cache-Control: Public
The public response directive indicates that a resource can be cached by any cache.

Cache-Control: Private
The private response directive indicates that a resource is user specific—it can still be cached, but only on a client device. For example, a web page response marked as private can be cached by a desktop browser, but not a content delivery network (CDN).

Additional HTTP Cache Headers
Expires – This header specifies a fixed date/time for the expiration of a cached resource. The expires header is ignored when a cache-control header containing a max-age directive is present.

ETag – A response header that identifies the version of served content according to a token – a string of characters in quotes, e.g., “675af34563dc-tr34” – that changes after a resource is modified. If a token is unchanged before a request is made, the browser continues to use its local version.

Vary – A header that determines the responses that must match a cached resource for it to be considered valid. For example, the header Vary: Accept-Language, User-Agent specifies that a cached version must exist for each combination of user agent and language.

Source: https://www.imperva.com/learn/performance/cache-control/

Leave a Reply