Chrome缓存像疯狂的浏览器 [英] Chrome caching like a mad browser

查看:119
本文介绍了Chrome缓存像疯狂的浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Web服务,像其他大多数人一样,使用js和css文件。我使用将版本号附加到js和css文件的旧技巧: ?v = 123,每当我们更新生产服务时就会更改。



现在,除Chrome之外,所有浏览器都能正常运行。 Chrome似乎更喜欢它的缓存版本而不是新版本,因此似乎忽略了附加变量。在某些情况下,强制它刷新缓存(cmd + r / ctrl + f5)是不够的,所以我必须进入选项并清除缓存以加载新内容。



有没有人遇到过Chrome的这个问题?如果是这样,这个问题的解决方案是什么?

解决方案

Chrome浏览器当然应该将不同的查询字符串视为不同的请求; style.css?v = 123 的缓存结果决不能用于 style.css?v = 124 。如果您看到不同的行为,请在 http://new.crbug.com/ 提交错误,并



也就是说,我首先会检查的缓存是否比您期望的要长。如果新版本的页面本身没有下载,那么它仍然会请求?v = 123 ,因为HTML不会改变。如果您使用该页面发送长期存在的缓存标头,则Chrome可能会比预期的更积极地缓存它。如果这是您所看到的行为,请以 http://crbug.com/8742 为主进行更新。


I've got a web service that, like most others, uses js and css files. I use the old trick of appending a version number to the js and css file like; ?v=123 and that gets changed every time we update the service on production.

Now, this works fine on all browsers, except for Chrome. Chrome seems to prefer it's cached version over getting the new one and therefor seems to ignore the appended variable. In some cases, forcing it to refresh cache (cmd+r / ctrl+f5) wasn't enough so I had to go into options and clear out the cache for it to load up the new content.

Has anyone experienced this issue with Chrome? And if so, what was the resolution to the problem?

解决方案

Chrome should certainly treat requests with varying query strings as different requests; a cached result for style.css?v=123 should never be used for style.css?v=124. If you're seeing different behavior, please file a bug at http://new.crbug.com/ and post the bug ID here.

That said, I'd first check to see whether the page was cached longer than you expected. If a new version of the page itself wasn't downloaded, then it would still be requesting ?v=123 as the HTML wouldn't have changed. If you're sending long-lived cache headers with the page, it's certainly possible that Chrome is caching it more aggressively than you expected. If that's the behavior you're seeing, please star http://crbug.com/8742 for updates.

这篇关于Chrome缓存像疯狂的浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆