Cache-Control for Civilians

This article is a repost promoting content originally published elsewhere. See more things Dan's reposted.

Cache-Control for Civilians – CSS Wizardry – CSS Architecture, Web Performance Optimisation, and more, by Harry Roberts

One of the most common and effective ways to manage the caching of your assets is via the Cache-Control HTTP header. This header applies to individual assets, meaning everything on our pages can have a very bespoke and granular cache policy. The amount of control we’re granted makes for very intricate and powerful caching strategies.

A Cache-Control header might look something like this:

Cache-Control: public, max-age=31536000

Cache-Control is the header, and each of public and max-age=31536000 are directives. The Cache-Control header can accept one or more directives, and it is these directives, what they really mean, and their optimum use-cases that I want to cover in this post.

A great reference for configuring your HTTP caching headers.

Leave a Reply

Your e-mail address will not be published. Required fields are marked *