使用查询字符串来版本化静态文件的缺点?
似乎为了强制用户刷新缓存的静态文件(例如,.css、.js),某些站点(例如,stackoverflow.com)将查询字符串附加到文件末尾。例如:
<link rel="stylesheet" type="text/css" href="http://sstatic.net/stackoverflow/all.css?v=9ea1a272f146">
我认为这是一个好主意,并且也倾向于开始这样做。但是,我听说它有缺点,例如如果存在查询字符串,代理无法正确缓存文件。
这种版本控制有哪些缺点?
It seems that in order to force users to refresh cached static files (e.g., .css, .js) some sites (e.g., stackoverflow.com) append querystrings to the end of files. For example:
<link rel="stylesheet" type="text/css" href="http://sstatic.net/stackoverflow/all.css?v=9ea1a272f146">
I think this is a good idea, and am inclined to start doing this as well. However, I have heard that there are downsides, such as proxies not properly caching files if a querystring is present.
What are the downsides to this type of versioning?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我只知道一个缺点:代理缓存(如您所说):
http://www.stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring/
http://paulirish.com/2010/announcing-html5-boilerplate/#comment-34976
(我发现了这些来自 http://www.html5boilerplate.com 中的评论)
受此影响的用户百分比应该非常低, 尽管。我已经使用这种技术有一段时间了,而且仍然如此。
Only one downside that I know of: proxy caching (as you said):
http://www.stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring/
http://paulirish.com/2010/announcing-html5-boilerplate/#comment-34976
(I found out about these from the comments in http://www.html5boilerplate.com)
The percentage of users affected by this should be very low, though. I've used this technique for quite a while, and still do.