问题描述
当主动缓存 CSS 和其他文件时,您可以通过重命名文件并链接到新副本(例如,style.123.css)来强制用户更新到最新版本的样式表重命名为 style.124.css).一种常用而不是重命名文件的不同方法是传递 URL 参数,(例如,style.css?ver=123,后来更改为 style.css?ver=124).
When aggressively caching CSS and other files, you can force the user to update to the latest version of the stylesheet by renaming the file and linking to the new copy (eg, style.123.css renamed to style.124.css). A different method often used instead of renaming the file is to pass a URL parameter, (eg, style.css?ver=123 which is later changed to style.css?ver=124).
是否所有浏览器都支持后一种下载样式表新副本的方法?与重命名文件相比,使用 URL 参数有什么缺点吗?
Do all browsers support the latter method for downloading a new copy of the stylesheet? Are there any disadvantages to using the URL parameter over renaming the file?
推荐答案
经过进一步研究发现,有些代理缓存服务不会缓存 URL 中带有查询字符串的文件.我不知道这是否适用于某些网络浏览器.
After further research, it turns out that some proxy caching services will not cache files with query strings in the URL. Whether this is true for some web browsers, I don't know.
所以这似乎是使用查询字符串更新主动缓存文件的唯一主要缺点 - 它们可能根本不缓存.
So this seems to be the only major disadvantage of using query strings to update aggressively cached files - they may not cache at all.
这篇关于主动缓存:所有浏览器都支持更新 URL 参数吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!