进行 html5 webapp 缓存时出现问题

发布于 2024-11-19 17:07:41 字数 1928 浏览 12 评论 0原文

我有一个网络应用程序,其域名 http://draft.mo2do.com

当我访问该网址时,它会像下面的 url 一样解析并重定向到相应的站点主页

http://draft.mo2do.com/s/_91665/Home

这里我实现了离线缓存。我的cache.manifest文件如下

   CACHE MANIFEST
   # Offline cache v4.0

   # All other resources (e.g. sites) require the user to be online.  

   NETWORK:

   *

   # Additional resources to cache CACHE:

   # Add the pages in to the cache 

   /s/_91665/Home /s/_91665/CachedDraftBoard

   http://draft.mo2do.com

   # Add the images in to the cache 

   /s/store/-1/webapp/styles/webapp.css

   /s/store/-1/webapp/styles/nba_draft.css

   /s/store/-1/webapp/styles/add2drafthome.css?v2  

   #  Add the js files in to the cache 

   /s/store/-1/webapp/scripts/jquery-1.5.min.js

   /s/store/-1/webapp/scripts/iscroll.js

   /s/store/-1/webapp/scripts/webapp.js

   /s/store/-1/webapp/scripts/nba_draft.js

   /s/store/-1/webapp/scripts/cacheUpdate.js

   /s/store/-1/webapp/scripts/add2drafthome.js?v0.9.4  



   /webapp/icon.png /webapp/startup.png

   /s/store/-1/webapp/nba/addtodrafthome/arrow.png

   /s/store/-1/webapp/nba/addtodrafthome/close-bubble.png

   /s/store/-1/webapp/nba/addtodrafthome/icon.png

   /s/store/-1/webapp/nba/addtodrafthome/plus.png

   /s/store/-1/webapp/nba/addtodrafthome/share.png

   FALLBACK: 

   http://draft.mo2do.com

如果我直接访问站点url,则缓存正在工作,当时我没有在缓存部分提到“http://draft.mo2do.com”。在此期间,离线缓存正在工作美好的。

如果我在浏览器中直接访问域网址“http://draft.mo2do.com”,则不会在离线模式下打开 404。

然后我在缓存部分添加了“http://draft.mo2do.com”,当时我收到异常

应用程序缓存进度事件(3 中的 2)http://draft.mo2do.com/ 应用程序缓存错误事件:资源获取失败 (-1) http://draft.mo2do.com/

如果我也访问该域,它应该以离线模式加载应用程序。如果我访问直接 url 应用程序加载正常。

我该如何解决这个问题?

I have a webapp which has the domain http://draft.mo2do.com

when i am accessing the url it will resolve like the below url and redirect to the corresponding site home page

http://draft.mo2do.com/s/_91665/Home

Here i implemented offline cache. My cache.manifest file is the below

   CACHE MANIFEST
   # Offline cache v4.0

   # All other resources (e.g. sites) require the user to be online.  

   NETWORK:

   *

   # Additional resources to cache CACHE:

   # Add the pages in to the cache 

   /s/_91665/Home /s/_91665/CachedDraftBoard

   http://draft.mo2do.com

   # Add the images in to the cache 

   /s/store/-1/webapp/styles/webapp.css

   /s/store/-1/webapp/styles/nba_draft.css

   /s/store/-1/webapp/styles/add2drafthome.css?v2  

   #  Add the js files in to the cache 

   /s/store/-1/webapp/scripts/jquery-1.5.min.js

   /s/store/-1/webapp/scripts/iscroll.js

   /s/store/-1/webapp/scripts/webapp.js

   /s/store/-1/webapp/scripts/nba_draft.js

   /s/store/-1/webapp/scripts/cacheUpdate.js

   /s/store/-1/webapp/scripts/add2drafthome.js?v0.9.4  



   /webapp/icon.png /webapp/startup.png

   /s/store/-1/webapp/nba/addtodrafthome/arrow.png

   /s/store/-1/webapp/nba/addtodrafthome/close-bubble.png

   /s/store/-1/webapp/nba/addtodrafthome/icon.png

   /s/store/-1/webapp/nba/addtodrafthome/plus.png

   /s/store/-1/webapp/nba/addtodrafthome/share.png

   FALLBACK: 

   http://draft.mo2do.com

If i am directly accessing the site url the caching is working and that time i didnt mention the "http://draft.mo2do.com" in the cache section.During this time offline cache is working fine.

If i directly access only the domain url "http://draft.mo2do.com" in the browser it is not opening 404 in the offline mode.

Then i added the "http://draft.mo2do.com" in the cache section that time i am getting exception

Application Cache Progress event (2 of 3) http://draft.mo2do.com/ Application Cache Error event: Resource fetch failed (-1) http://draft.mo2do.com/

If i access the domain also it should load the app in the offline mode. If i access direct url app is loading fine.

How can I solve this issue?

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

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

发布评论

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

评论(1

我是男神闪亮亮 2024-11-26 17:07:41

缓存必须直接引用特定资源,无论是 Javascript、CSS、HTML 页面、图像等等。从上面的内容来看,你已经做到了。然而,简单地在其中放置一个域是行不通的(您还需要引用所有您想要离线的页面,例如/s/_91665/Home需要在那里)。

所以,沿线的某个地方有一个错误,但很难弄清楚你的意思:

如果我在浏览器中直接访问域网址“http://draft.mo2do.com”,则不会在离线模式下打开 404。

你能说得更清楚吗?您的意思是访问该 URL 会导致 404,还是页面本身存在错误?

您确定您的缓存文件按预期运行吗? 如果您的缓存文件中存在任何错误,您的离线应用程序将无法运行。此页面提供了一些可能有帮助的调试代码:

调试 HTML 5 离线应用程序缓存

The cache has to directly reference specific resources, be they Javascript, CSS, HTML pages, images, whatever. From what I can tell from the content above, you've done that. Simply placing a domain in there however won't work (you also need to reference all of the pages you want off-line, e.g. /s/_91665/Home needs to be in there).

So, there's an error somewhere along the line, but it's hard to figure out what you mean by this:

If i directly access only the domain url "http://draft.mo2do.com" in the browser it is not opening 404 in the offline mode.

Can you be more clear? Do you mean that going to that URL results in a 404, or is there something in the page itself that's in error?

Are you sure that your cache file is functioning as intended? If there are any errors at all in your cache file, your off-line application simply won't work. This page offers some debugging code which may help:

Debugging HTML 5 Offline Application Cache

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