从 Javascript 设置 HTML5 缓存清单

发布于 2024-12-20 02:34:49 字数 453 浏览 4 评论 0原文

我正在服务器端生成缓存清单,并且需要通过查询字符串包含一些信息。

我的问题是,我需要包含的信息只能通过使用 Javascript 来获取。因此需要加载页面,然后进行一些 javascript 处理,最后设置清单 url(并更新缓存)。

所以本质上:

$("html").attr("manifest", "/cache.manifest?varfromjs= + somevar);

但这没有任何作用,我尝试调用 window.applicationCache.update(),但我收到一条错误消息“INVALID_STATE_ERR: DOM Exception 11”,

这是在最新稳定的 Google Chrome 上,但这似乎

是我的第一个 。使用 HTML5 appcache 的时间,所以我可能错过了一些东西,我应该如何做呢?

I'm generating the cache manifest serverside, and I need to include bits of information through querystrings.

My problem is, that the information I need to include is only obtainable by using Javascript. So the page needs to load, then some javascript processing, and finally setting a manifest url (and update the cache).

So in essence:

$("html").attr("manifest", "/cache.manifest?varfromjs= + somevar);

This does nothing though, and I've tried calling window.applicationCache.update(), but I get an error stating "INVALID_STATE_ERR: DOM Exception 11".

This is on latest stable Google Chrome. It seems to work in Firefox though.

This is my first time using HTML5 appcache, so I may have missed something. How should I go about doing this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

娇纵 2024-12-27 02:34:49

我不认为可以动态添加缓存清单属性,请尝试在服务器端进行处理。

I don't think cache manifest attribute can be added dynamically, try doing your processing on server side.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文