3

我有一个域名为http://draft.mo2do.com的 webapp

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

http://draft.mo2do.com/s/_91665/首页

这里我实现了离线缓存。我的 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”。在此期间,离线缓存工作正常。

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

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

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

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

我该如何解决这个问题?

4

1 回答 1

0

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

因此,沿线某处存在错误,但很难弄清楚您的意思是什么:

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

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

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

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

于 2011-07-13T11:11:50.473 回答