开发者

Boilerplate Cache Busting Question

开发者 https://www.devze.com 2023-01-31 00:35 出处:网络
1) I\'m confused about the purpose of setting header expiry dates for caching css and js files (like how it\'s done in the

1) I'm confused about the purpose of setting header expiry dates for caching css and js files (like how it's done in the Boilerplate .htaccess file).

I thought web browsers automatically cache css and js files. What's the point of setting header expiry dates?

2) Is there a way to NOT use versioning of css and js files and still have them automatically update when I upload them to a server. I tried setting a lower expiry date ("access plus 1 week" and "access plus 0 seconds") and the browser was still displaying the old cached copy when I uploaded updated css and js files. I'm not 100% sure I did this correc开发者_StackOverflowtly, though.

Thanks :)


1) Some browsers don't cache things that do not have an expiration date.

2) Try appending a get variable to the end of your URL string to new versions of your website to ignore previous versions cache. The idea is to transform your urlstring into something like www.example.com/?v=1 and then when you change that to www.example.com/?v=2 the browser does not recognize this url so it doesn't use any cached files. When a user goes back to www.example.com/?v=2 it will access the cached files for v2 of your website

0

精彩评论

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