ASP.NET 清单文件脚本未刷新
我正在使用 MVC 和 JS 来创建一个 iPad 应用程序。关键要求之一是应用程序能够在离线模式下工作。因此,我使用清单文件来确定缓存的脚本文件。但是,我希望当浏览器再次在线时刷新所有脚本。我已通过以下方式指定了这一点:
Network:
*
在我的脚本下面的清单文件中。但这不起作用,因为在线刷新浏览器时某些文件不会更新。此外,如果我检查 Chrome 中的开发人员工具,控制台会显示以下事件:
Application Cache Checking event
Application Cache NoUpdate event
我猜这意味着浏览器尝试更新缓存,但未找到更新。
有什么想法吗?
请参阅下面我的完整清单文件:
CACHE MANIFEST
#rev20
# Explicitly cached entries
../css/sencha-touch.css
../Site.css
../css/mycss.css
../css/application.css
../../Scripts/SenchaTouch/sencha-touch-debug-w-comments.js
../../Scripts/js/Base/Index.js
../Images/Icons/green_indicator.png
../Images/Icons/red_indicator.png
../Images/toolbar_image.png
../Images/search_icon.png
../Images/loading.gif
NETWORK:
*
编辑:
我最初的想法是文件一旦更改就会自动更新。但是,因为浏览器依赖清单文件来通知它发生更改(我认为),所以当发生更改时,#rev
数字需要递增。即使这样,当我测试时,我也不需要刷新页面几次才能让它重新加载文件。我怀疑这与浏览器加载和处理资源的顺序有关,但我找不到任何相关信息。
I am using MVC together with JS to create an IPad app. One of the key requirments is for the app to work in offline mode. Thus I am using a manifest file to determine the cached script files. However, I would like to have all scripts be refreshed when the browser is again online. I have specified this by:
Network:
*
in the manifest file underneath my scripts. This does not work though because some of the files are not updated when the browser is refreshed online. Furthermore, if I check the developer tools in chrome, the console shows the following events:
Application Cache Checking event
Application Cache NoUpdate event
Which I guess means that the browser tried to update the cache but no update was found.
Any ideas?
See below my full manifest file:
CACHE MANIFEST
#rev20
# Explicitly cached entries
../css/sencha-touch.css
../Site.css
../css/mycss.css
../css/application.css
../../Scripts/SenchaTouch/sencha-touch-debug-w-comments.js
../../Scripts/js/Base/Index.js
../Images/Icons/green_indicator.png
../Images/Icons/red_indicator.png
../Images/toolbar_image.png
../Images/search_icon.png
../Images/loading.gif
NETWORK:
*
EDIT:
My initial idea was that the files will be automatically updated once they are changed. However, because the browser relies on the manifest file to notify it for the changes (I think), the #rev
number needs to be incremented when there is a change. Even then, when I tested I needed t refresh the page a couple of times to get it to reload the files. I suspect that has something to do order in which the browser loads and handles the resource but I could not find any info on that.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
浏览器仅在检测到缓存清单发生更改时才会更新缓存。增加修订版本号是强制进行更改的好方法。
浏览器检测到更改后,就会下载文件并准备新版本的缓存。浏览器不会使用新的缓存,直到它完全满并且您刷新页面。
您可以使用以下 javascript 检测新缓存何时准备就绪并刷新页面以立即开始使用它:
The browser will only update the cache when it detects that there is a change to the cache manifest. Incrementing your revision number is great way to force that change.
After the browser detects a change, then it downloads the files and prepares the new version of the cache. The browser won't use the new cache until it is completely full and you refresh the page.
You can detect when the new cache is ready and refresh the page to start using it immediately using this javascript: