HTML5:如果在同一 URL 下加载不同页面,则忽略离线缓存
我有一个具有恒定 URL 和内部状态机的 Web 应用程序。状态是通过帖子改变的。我知道这是一个糟糕的设计,我应该使用其他方法。但鉴于此我有以下问题。
我使用HTML5离线缓存(HTML标签中的manifest属性)。对于第一页,它按照我的预期进行解析和缓存(登录页面)。但对于第二页(主菜单),其中包含的清单未被解析。 Chrome 浏览器内不显示任何事件。如果我通过包含参数稍微更改 URL,则清单会被解析,但之前不会。
如果我在登录页面清单中包含所有内容,则第二页会再次下载相同的文件。如果在第一页的清单中指定了它们,则发生事件。
为什么会有这种行为?
I have a web application that has a constant URL and internal state machine. The states are changed via posts. I know it is a bad design and I should use the rest approach. But given this I have a following problem.
I use HTML5 offline cache (the manifest attribute in HTML tag). For the first page it is parsed and cached as I would expect (login page). But for the second page (main menu) the manifest included there is not parsed. No events are shown inside Chrome browser. If I change the URL a little by including a parameter then the manifest is parsed, but not before.
Event if I include everything in the login page manifest the second page downloads the same files again. Event if they are specified in the manifest for the first page.
Why this behaviour?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我自己来回答一下。它看起来很奇怪,只是因为缓存仅在 GET 调用时解析,而在 POST 调用时被忽略。 post 加载另一个 HTML 页面时发生的事件。对我来说,这有点愚蠢,但似乎就是这样。
现在它终于按预期工作了。
To answer it myself. It was looking so odd, simply because the cache is only parsed on GET calls and ignored on POST calls. Event if post loads another HTML page. To me this is a little bit silly but it seems that is how it works.
Now it finally works as it is supposed to.