AppCache 不交换 index.html
AppCache does not swap index.html
我已经使用未更改 index.html 的 appcache 很长一段时间了。它没有在清单中明确列出,但无论如何都作为主条目缓存。
现在 index.html 发生了变化,我 运行 遇到了这个问题:
所有资源都已正确获取和缓存,但主条目仍然很旧并且网站中断。我尝试在清单中明确列出 index.html。 Chrome devtools 很好地展示了困境:
旧的index.html仍然是主人。新的被显式缓存但不交换。
此错误如 Chrome 中所述发生。 FF 和 Safari 工作正常。 IE 11 显示 "Resource doesn’t exist on the server" 和 "Appcache Fatal Error".
清单如下所示:
CACHE MANIFEST
# vX.X.X
NETWORK:
*
CACHE:
index.html
app.js
app.json
favicon.ico
... (+100 more files)
找到了:
为了修复一个框架错误,我有一个 server-side 重定向来添加一个查询字符串参数。从 https://example.com to https://example.com?myparam 交换应用程序缓存破坏了 Chrome 和 IE 中的应用程序缓存。
遇到同样的问题并在没有服务器端操作的情况下解决了它。
所以您只需将脚本添加到您的 <head>
标签:
<script type="text/javascript">
window.applicationCache.addEventListener("updateready",
(event) => { window.location.reload(true) });
</script>
如果您感兴趣,可以在我的 post 此处找到一些解释:
AppCache doesn't swap index.html file
我已经使用未更改 index.html 的 appcache 很长一段时间了。它没有在清单中明确列出,但无论如何都作为主条目缓存。
现在 index.html 发生了变化,我 运行 遇到了这个问题:
所有资源都已正确获取和缓存,但主条目仍然很旧并且网站中断。我尝试在清单中明确列出 index.html。 Chrome devtools 很好地展示了困境:
旧的index.html仍然是主人。新的被显式缓存但不交换。
此错误如 Chrome 中所述发生。 FF 和 Safari 工作正常。 IE 11 显示 "Resource doesn’t exist on the server" 和 "Appcache Fatal Error".
清单如下所示:
CACHE MANIFEST
# vX.X.X
NETWORK:
*
CACHE:
index.html
app.js
app.json
favicon.ico
... (+100 more files)
找到了:
为了修复一个框架错误,我有一个 server-side 重定向来添加一个查询字符串参数。从 https://example.com to https://example.com?myparam 交换应用程序缓存破坏了 Chrome 和 IE 中的应用程序缓存。
遇到同样的问题并在没有服务器端操作的情况下解决了它。
所以您只需将脚本添加到您的 <head>
标签:
<script type="text/javascript">
window.applicationCache.addEventListener("updateready",
(event) => { window.location.reload(true) });
</script>
如果您感兴趣,可以在我的 post 此处找到一些解释: AppCache doesn't swap index.html file