缓存清单离线应用程序不会在 Chrome 中刷新 javascript 文件
我正在使用缓存清单文件开发离线网络应用程序。我在刷新 javascript 文件时遇到问题。如果我更改 .js 文件(在清单文件中列出),然后更改清单文件版本号。并保存它,则更改后的 .js 文件不会在客户端上重新加载。我需要做什么才能刷新 .js 文件?
谢谢
I am working on an offline web app using a cache manifest file. I am having trouble refreshing my javascript files. If I change a .js file (which is listed in the manifest file) and I then change the manifest file version no. and save it, then the changed .js file does not get reloaded on the client. What do I have to do to get .js files to refresh?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
这是因为网络服务器告诉浏览器缓存静态文件几个小时。所以浏览器不知道清单文件已更改。您可以清除所有应用程序数据“或”配置 Web 服务器,清单不可缓存...
阅读 http:// divintohtml5.info/offline.html 了解更多信息
如果您想清除 Chrome 上的应用缓存,请使用 chrome://appcache-internals/
并手动搜索 C:\Documents and Settings\YOURUSERNAME\Local Settings\Application Data\Google\Chrome\User Data\Default\Cache
That's because the webserver tells the browser cache static files for a few hours. So the browser doesn't know the manifest file is changed. You can clear all the application data 'or' config the web server the manifest is not cacheable...
Read http://diveintohtml5.info/offline.html for more info
If you want to clear your app cache on chrome use chrome://appcache-internals/
and by hand you have to search in C:\Documents and Settings\YOURUSERNAME\Local Settings\Application Data\Google\Chrome\User Data\Default\Cache
我假设如果您使用缓存清单然后刷新清单,浏览器将再次请求所有文件。但是,我发现我需要在清单中的所有文件中显式设置标头,以告诉浏览器不要缓存文件。我相信,一旦清单告诉浏览器再次请求该文件,浏览器就会像对待任何其他非清单缓存文件一样对待它。也许这是 Chrome 的一个错误,但我感觉我在另一个 WebKit 浏览器中看到了这个。
无论如何,将清单中文件的标头设置为永远不会缓存,并且在更新清单时应重新加载它们。如果这些文件在清单页面之外使用,您可能需要根据需要实际缓存这些文件。
I had assumed that you if you use a cache manifest and then refresh the manifest, that the browser would request all of the files again. However, I have found that I needed to explicitly set headers in all of the files in the manifest to tell the browser not to cache the files. I believe that once the manifest tells the browser to request the file again, the browser treats it like any other non-manifest cached file. Maybe this is an error with Chrome, but I feel like I saw this in another WebKit browser.
Regardless, set the headers for the files in the manifest to never be cached and they should reload when you update the manifest. If these files are used outside of a manifest page, you may need to actually cache the files depending on your needs.
在地址栏中输入
chrome://appcache-internals
,然后单击 ENTER将出现缓存清单列表,然后只需删除您想要的清单,当您再次加载页面时,所有内容都会刷新。
希望这有帮助:)
Type
chrome://appcache-internals
in your address bar then click ENTERA list of cached manifests will appear then just delete the one you want and everything will be refreshed when you load your page again.
Hope this helps :)
我遇到了同样的问题,直到我在网上发现了这个无价的警告
Mozilla 开发者网站
哎呀。我的错。
但是,每次我更改代码中的某些内容时,我都需要更改清单中的某些内容,然后重新加载两次,这是一个不相关的问题。
I had the same problem until I came across this priceless warning on the
Mozilla Developer site
woops. my bad.
However, every time I change something in the code, I need to change something in the manifest, and then reload twice, which is an unrelated issue.
就我而言,我必须使用元标记禁用传统的浏览器缓存。请参阅这个问题如何解决
In my case, i has to disable the traditional browser cache using meta tags. See this SO question how to that