Used to control how the response can be cached by any mechanism along the response chain.

When a server sends a webpage or image to a client web browser, it is typically valid for a certain duration, allowing the browser to store the resource in its cache. If the resource is requested again (e.g. due to a page reload), the browser can swiftly retrieve the cached value instead of fetching it from the server. Caching plays a crucial role on the internet as it speeds up page loading times and alleviates the server's load and bandwidth requirements. Furthermore, there may be extra caching layers (some of which you do not control) between the server and client, such as a content delivery network, which can further reduce the load and bandwidth usage.

The Cache-Control header allows you to specify how the resource is allowed to be cached by various caching layers along the chain from request to response. To prevent a response from being cached, set the header to no-store and every request will now go to the origin server to receive a response. This would be appropriate for a webpage that shows frequently updated information. Static files that are not changed frequently should be allowed to be cached by the browser and/or other layers. For example, you may allow images to be cached by setting their header as in the example below.

Cache-Control: public, max-age=604800, immutable

The Expires Header is an older way to control caching that may still be necessary if you want to support older HTTP/1.0 clients.

For more information about the specific values that you can set for this header, please read the documentation on MDN Web Docs.

Ready to validate your website to check for this header and 100+ others important tests?