The Flow of Events
So far, Iâve talked about offline web applications, the cache manifest, and the offline application cache (âappcacheâ) in vague, semimagical terms. Things are downloaded, browsers make decisions, and everything âJust Works.â You know better than that, right? I mean, this is web development weâre talking about. Nothing ever âJust Works.â
First, letâs talk about the flow of events, specifically
DOM events. When your browser visits a page that points to a cache
manifest, it fires off a series of events on the window.applicationCache
object, as I
describe below. I know this looks complicated, but trust me, this is the
simplest version I could come up with that didnât leave out important
information. Hereâs the process:
As soon as it notices a
manifest
attribute on the<html>
element, your browser fires achecking
event. (All the events listed here are fired on thewindow.applicationCache
object.) Thechecking
event is always fired, regardless of whether you have previously visited this page or any other page that points to the same cache manifest.If your browser has never seen this cache manifest before:
It will fire a downloading event, then start to download the resources listed in the cache manifest.
While itâs downloading, your browser will periodically fire
progress
events, which contain information on how many files have been downloaded already and how many files are still queued to be downloaded.After all resources listed in the cache manifest ...
Get HTML5: Up and Running 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.