Problem While Doing html5 webapp cache

2019-07-04 11:02发布

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?

1条回答
我欲成王,谁敢阻挡
2楼-- · 2019-07-04 11:38

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

查看更多
登录 后发表回答