Chapter 7. Taking It Offline

The Internet may seem to be always on these days but, let’s be honest, it’s not. There are times and places when even the most modern mobile devices are out of range of the network for one reason or another.

Chapter 4 looked at how to have data stored local to the browser so that it does not require network access to use. However, if the web page on which the application is hosted is not available, having the data handy will be of no use.

With more and more of the modern application infrastructure moving into the browser, being able to access this software at any time has become critically important. The problem is that the standard web application assumes that many components, including JavaScript sources, HTML, images, CSS, and so forth, will be loaded with the web page. In order to be able to use those resources when the user does not have access to the Internet requires that copies of those files be stored locally, and used by the browser when needed. HTML5 lets a programmer give the browser a listing (known as a manifest) of files that should be loaded and saved. The browser will be able to access these files even when there is no network connection to the server.

The files listed in the manifest will also be loaded from the local disk even if the browser is online, thus giving the end user the experience of the ultimate content delivery network.

As long as the browser is online when a page is loaded, it will check the manifest file with the server. ...

Get Programming HTML5 Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.