HTML5 features appcaching, a way to make your web sites and apps work offline, and to increase their performance as well.
An appcache manifest contain several lines in that order:
- In the first line we declare “CACHE MANIFEST” (required)
- Second line: “CACHE:” – which specifies the URLs of resources.
- We can also optionally specify which resources should not be cached, in a section of the manifest file introduced by the string “NETWORK:”. These resources aren’t just not cached, but further, won’t be used when the user is offline, even if the browser has cached them in its own caches.
- We can also optionally specify fallback resources to be used when the user is not connected, in a section of the file called “FALLBACK:”
- You can add comments to the file with, simply by beginning a line with “#” – that’s an important feature to make the version readable for you as a developer. It’s also a nice way to let the browser ‘know’ that something changed in our app and it’s needed to fetch a new version of the app from the network.
Here is a simple example:
Creating a HTML5 cache manifest file the easy way:
- manifested – cool tool to save you time and from what I’ve tried it works.
- http://westciv.com/tools/manifestR/ – It is a bookmarklet, which you drag to your bookmarks bar. Then, when you visit any page, you can click the manifestR button, and it will create an HTML5 appcache manifest file for that page.
- Some code to play with: https://github.com/jamesgpearce/confess