Luca Matteis
Luca Matteis

Reputation: 29267

Caching static content

I'm trying to understand what's the best Cache-Control value to be set for static content (images, css, javascript). The issue with this is that my JavaScript/CSS is still very much in development, and whenever I make a change I want people to see changes immediately (they shouldn't have to reload their cache).

What's the best way to go about this? Should I add a ?version=1000202210 after each static request so the browser knows it's new?

Upvotes: 2

Views: 4175

Answers (1)

alienhard
alienhard

Reputation: 14692

Yes, a long expiration date + fingerprinting brings you maximal browser caching and at the same time the necessary flexibility to propagate changes immediately. Google page speed has a good explanation. You can either add a fingerprint in the query string or in the path of the assets. It doesn't really matter how you do it as long as the URL changes when you want the resource to be fetched again.

Upvotes: 5

Related Questions