我看不到 AppCache 清单的用途,因为您想绕过缓存并只使用网络。请记住,无论 AppCache 清单如何,常规缓存可能仍然适用,因此请检查Expires
,Last-Modified
和类似的标头。
至于你的问题:
注意:更新清单时,浏览器会重新下载资产,但仍会显示旧版本……只有在下次加载时,浏览器才会使用新资产。为什么 ?
这是因为用户代理将立即使用您的资产的最新缓存版本,然后开始检查清单中列出的链接资源是否有更新。当用户代理检测到清单已更改,因此它必须检查更新时,它将触发一个checking
事件。
When the update checking process has finished (and it might take a long time, if you have lots of resources) it will fire an updateready
event. Only the resources fetched after this event will be the fresh new ones (that's why it's usually adviceable to use window.applicationCache.swapCache()
to tell the browser to swap the old cache for the new for the next page load, or simply reload the page and be done with it).
You will find more detailed explanations about these topics here: http://www.html5rocks.com/en/tutorials/appcache/beginner/