开发者

css/javascript caching in firefox (and other browsers) how does it work

Lets say I have an application that updates it javascript/css files (and keeps the same file names)

How can you force a client to not serve files from cache an开发者_开发百科d use the new javascript/css. I have a feeling a bug is being caused by this. I still want the files to cache, so appending a random string to the css/js include will NOT be good.


Append the date the file was changed to the CSS/JS file request. Many frameworks can do this for you, depending on your technology stack.


Even better is to put a version number in the filename and each time you revise the file, you modify the version number in the filename and modify the source page that loads it to point to the new filename. Then you get maximum caching possible when the file hasn't changed, but when you do change the file you immediately get the new version. This technique is used by many sites on the web for exactly this reason.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜