I’m thinking about what caching strategy I want to implement for a static file server. This is subjective for the person, but I think I’m going to go with something like this.
(this part is not Caddy-specific, but it’s relevant)
- HTML/XML will get
Cache-Control: must-revalidate
my html changes regularly, so caching it is fine, but I want the browser to revalidate it so users get the changes without an additional refresh - everything else gets
Cache-Control: max-age: 31536000, immutable
my static assets, mostly images, don’t change. if something did change, the filename would change
my front-end assets like css and js get cache busted by putting a hash in the filename
(the Caddy-specific part)
I’m thinking about making a snippet that sets the Cache-Control
header by matching the Content-Type
header. I’ll be posting a Caddyfile example in a bit.
I’d love feedback if anyone has any.