David Jones

The anatomy of a cache manifest

A cache manifest is a list of resources that your application will need to have access to in order to operate in a offline environment. Your cache manifest file must be referenced on every page of your application.

The first line of your cache manifest file must always be:

CACHE MANIFEST

It is always useful to put a version number as a comment on the second line.

You can then start adding resources to your cache manifest file. Below is a simple example cache manifest file.

CACHE MANIFEST
#0.1
styles.css
image.jpg
javascript.js

You might not have to include any html pages in your cache manifest file as long as your include the reference to your cache manifest file.

The fallback section is where you define where your application should go if your user tried to access a resource that is not found in the application cache or there was a issue and caching it was unsuccessful. For example you could do this.

FALLBACK:
/ /offline/offline-error.html

This basically says if a resource could not be found in the application cache file then serve the file /offline/offline-error.html. The single / at the beginning of the line tells our application that it should match any page on our site not just the home page.

The network section is a list of resources that are never cached so they will never be available offline. There is also the * character that tells our application to download any extra resources that are needed if the user is viewing the offline website with a internet connection.

NETWORK:
*