开发者

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 reloa开发者_运维技巧d 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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜