HTML and CSS Reference
In-Depth Information
Offline Application Events
In the preceding sections, you created an offline application by creating a cache manifest. The browser did
all the work of downloading and storing the application files in a local cache. When the browser is busy
downloading and caching an application, it raises several applicationCache object events.
applicationCache is an object whose properties, methods, and events can be handled using JavaScript
code. Using applicationCache events, you can track various stages of an offline application's life cycle. Let's
see what kind of events the applicationCache object fires:
Whenever you request a web page whose manifest attribute points to a cache
manifest file, the checking event of the applicationCache object is raised. The
checking event is raised regardless of whether the application is already cached.
If the browser has never cached this application before, it downloads the
application's cache manifest as indicated in the manifest attribute and begins
downloading files as listed in the cache manifest. At the same time, the
downloading event of the applicationCache object is raised.
The cache manifest may contain many files, and the downloading operation
may be lengthy. That is why periodically the applicationCache object raises a
progress event notifying you about the progress of the download operation.
After all the files listed in the cache manifest are downloaded, the
applicationCache object raises the cached event. This event is an indication that
the entire application is now available offline.
If you're accessing an application that is already cached, the browser checks
whether the application's cache manifest file has changed since the last
If the cache manifest file is unchanged, there is no need to update the offline
cache, and the noupdate event of the applicationCache object is raised.
If the cache manifest has changed since the last download, the browser begins
downloading the application files and raises the downloading and progress
events of the applicationCache object as before.
When all the application files have been successfully downloaded, the
updateready event of the applicationCache object is raised.
9. It's also possible that an application that was cached earlier is no longer an
offline application—that is, its cache manifest has been removed from the
server. In this case, the browser raises the obsolete event of the
applicationCache object and removes the existing files from the cache. The
application is now treated as a connected application and needs a live network
connection with the server in order to function properly.
10. If there is an error in any of the previous steps, the error event of the
applicationCache object is raised.
The applicationCache object events just discussed are listed in Table 8-2 for your convenience.
Search WWH ::

Custom Search