开发者

What is the proper way of utilizing browser cache without using expiration?

开发者 https://www.devze.com 2023-02-26 06:16 出处:网络
I don\'t want to use expiration, because I don\'t know how often my resources (css, js, etc) will change. A case might be where I push something to production, but soon find out I have some bugs in th

I don't want to use expiration, because I don't know how often my resources (css, js, etc) will change. A case might be where I push something to production, but soon find out I have some bugs in the resources. So I fixed the bugs, then push the updated resources into production, but they're in production before the expirati开发者_如何学编程on date. How do I force the browser to use the updated resources instead of cache?

I don't want to use fingerprinting (dynamic resource filename based of version type), because those resources are located in an svn directory. Meaning, I would have to manually modify the filename using svn every time I change the code version (maybe there's somewhat to automate this?).

Utilizing http-equiv="last-modified" would be the preferred option, but that doesn't seem to work properly.

Also maybe I just don't know how all this works. Please enlighten me. Many thanks in advance.

-- Tri


One option would be to have all references to those resources to append a version number to the query string or elsewhere in the URL, for example "styles/site.css?version=1.0". That way, since the URL will change during your next release, your browser will see it as a different URL and will not use the file from cache.

If you ever change to using a CDN, deploying all resources to version numbered folders can achieve the same goal.

0

精彩评论

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

关注公众号