Cache Control for WEB pages

Getting your Trinity Audio player ready...
pt flag
en flag
es flag
Voiced by Amazon Polly

Cache-Control is an HTTP header that consists of a set of settings that allows you to specify how, when, and for how long a cache will take place.

When you visit a website, your browser copies parts of that website's components to a directory for a faster experience. When you revisit that site, many parts of the site are not loaded from the web server, but from the cache that is on your machines. You can use Cache-Control to define the rules for how that content will be loaded, such as how long the browser can cache, whether it will cache a component or a specific type of file.

It's important to understand that cache is very good for the end user experience. Making it have to go to your web server for all requests can make the experience with your product unpleasant, but it's much more important to understand what can actually be left on the user's machine and what should be loaded dynamically regardless of the user's side. After all, depending on your content type, a poorly configured page, a poorly configured component, or a chat-bot where there needs to be more dynamic communication may be impacted.

Cache-Control: no-cache

no-cache means that the resource cannot be reused without first checking if it was changed or updated at its source. Usually an ETag header is used for this.

Cache-Control: no-store

no-store is similar to no-cache where content cannot be reused or cached. However, unlike the other option, no-store forces all content to be downloaded again from the source, disregarding ETag.

Cache-Control: public

A response containing public means that the cache is authorized to be done by any party involved, not just the end customer, in this case we are talking about intermediate caches such as proxys, gateways, CDN's, etc.. For this situation, it is recommended that max-age be added to ensure that at some point the cache, both the end user and the intermediary, are cleaned.

Cache-Control: private

The private option means that only the applicant's browser can cache the content, and intermediaries should not cache the content.

Cache-Control: max-age= seconds

This option indicates to the browser how long it should consider the content of that cache as usable. After the end of that time, new requests must reload the entire content.

Cache-Control: s-maxage= seconds

s-maxage is similar to max-age. The “s” stands for shared and is relevant only for CDNs or other intermediate cache. This option overrides max-age and expires.

Cache-Control: no-transform

Intermediate caches can sometimes change the format or compression of images to improve performance. The no-transform tells intermediaries not to change the format of the images.

Leave a Reply

Your email address will not be published. Required fields are marked *