The HTML5 Application Cache API provides a mechanism for caching the files and resources used by a web page. Once cached, it's as if the user downloaded and installed your application on their device. This allows the application to be used offline when the user is not connected to the Internet.
The key to getting your application cached is the cache manifest file. This file is a simple text file that contains information about what resources should be cached. It is referenced by the manifest
attribute on the <html>
element of your web page:
<html manifest="myapp.appcache">
Inside the manifest file, you can specify the resources to cache or not cache. The file can have three sections:
CACHE
: This is the default section and lists the files to be cached. Declaring this section header is optional. Wildcards are not allowed in URIs.NETWORK
: This section lists the files that require a network connection. Requests for these files bypass the cache. Wildcards are allowed.FALLBACK
: This section lists fallback files if a resource is not available offline. Each entry contains the URI of the original file and the URI of the fallback file. Wildcards are allowed. Both URIs must be relative and from the same domain as the application.One important thing to note is that once the files for an application are cached only those versions of the files will be used, even if they change on the server. There are only two ways that the resources in the application cache can be updated:
I recommend keeping the cache manifest file out of the same folder as your HTML file while developing your application. You don't want files cached while you are writing code. Put it in the base folder of your application along with your release script and copy it to the release
folder in your script.
Whether you cache your application or not depends on the nature of your application. If it heavily depends upon Ajax calls to the server to work then making it available offline would be pointless. However, if you can write your application so that it stores data locally while offline, then it might be worthwhile. You should determine if the overhead of maintaining a cache manifest provides a benefit to your application.
18.220.1.239