3
votes

I am developing a web app in which I am trying to use the HTML5 application cache.

I am running the application on apache tomcat 7. When the server is running it's OK; file downloads in Google Chrome and I get cached or update ready event. But once I shut down the server and refresh the page, I get an error manifest fetch fail (-1).

How to get over this error and why does it occur?

my manifest file is as follows(sample.manifest):

CACHE MANIFEST

# version 4
CACHE:

css/styles.css

js/script.js

js/jquery-latest.js

js/jquery.validate.js

img/blue-line.png

img/main-img.png

img/logo.png

img/green-li.png

img/gline2.png

img/gline3.png

img/gline4.png

img/gline5.png

img/diversity-img.jpg

img/facebook32.png

img/mail40x32.png

img/main-img-298.png

img/ppl-img.jpg

img/twitter32.png

leavevbc.html

diversity.html

NETWORK:

*

I added the correct MIME type but I'm still getting the problem.

2
… but does the content render as expected when you're off-line? If so, your manifest file is working so you're good to go. - Ben

2 Answers

14
votes

The manifest load fail error is exactly what you have to expect if the server can't be reached. The manifest can't be loaded. It's a little bit confusing that this is reported as an error - but that's what the standard says. All you have to do is ignore the error and you should have an offline cached webapp.

0
votes

In Chrome, inspect all your app cached items. You may be surprised to see that what is inside of your cached files are not what you put into them. I've run into this exact situation. I had a javascript file that contained my FALLBACK: offline.html page. The Webkit cache loader has issues when the type of content its loading is not what it expects. To me this is just wrong, but on the upside, it did reveal the problem. In my case, it looked in my js file and crimped when it saw the at the top of the file.

If there are resources that must be pulled when online only then list them in NETWORK: section.

To fix current situation do following:

  • clear out your browser cache
  • change comment at top of your manifest file so that new copy will be downloaded
  • fire up chrome with developer tools
  • pull down web page while online
  • inspect your chrome application cache files again
  • go offline and browser refresh

http://www.html5rocks.com/en/tutorials/appcache/beginner/