4

Please explain FALLBACK section in .appcache file. What should the file offline.html contain. What is the difference between CACHE SECTION and FALLBACK SECTION. I am able to understand that Cache section may contain css and js files, but what is the use of fallback section.

When i give something like the following in my demo.appcache

 CACHE:
 style.css
 script.js

 NETWORK:
 *

 FALLBACK:

Does this mean that excluding style.css and script.js all other files need a network connection?

Please explain

1 Answers1

5

Fallback is the html document (and any supporting css and js files) to be served if there is no offline version found and you are not connected to the internet.

This is a good explanation of all sections: http://diveintohtml5.info/offline.html

FALLBACK:
/ /offline.html

Now look at the fallback section. The fallback section in this cache manifest only has a single line. The first part of the line (before the space) is not a URL. It’s really a URL pattern. The single character (/) will match any page on your site, not just the home page. When you try to visit a page while you’re offline, your browser will look for it in the appcache. If your browser finds the page in the appcache (because you visited it while online, and the page was implicitly added to the appcache at that time), then your browser will display the cached copy of the page. If your browser doesn’t find the page in the appcache, instead of displaying an error message, it will display the page /offline.html, as specified in the second half of that line in the fallback section.

mattdlockyer
  • 6,984
  • 4
  • 40
  • 44