HTML and CSS Reference
In-Depth Information
<html lang="en" class="blue" manifest="tasks.appcache">
We're almost there. In the final step, you will give My Tasks the ability to detect changes
in the manifest file. My Tasks will use this ability to determine when to download a newer
version of My Tasks.
5.4.3. Automating application updates
When you created the cache manifest file, you used a comment with a revision number to
update the manifest, to document changes in the manifest or in one or more of the web re-
sources listed in the manifest. This practice has a function beyond documentation; it can
also be used to detect and trigger application updates.
If any change is made to the text in the manifest, the application will download the new
manifest and all files listed in the CACHE MANIFEST or CACHE section. When this is
done, a new cache is created and an updateready event is fired. To update the applic-
ation, you have to attach an event handler to updateready. The handler will swap the
old cache for the new one, then ask the user for permission to update the application. If the
user grants permission, the event handler will force an application reload. The reload en-
sures that resources from the new cache are loaded into the application. If the user declines
the update, the application will use the new cache the next time the user loads the applica-
tion.
Now, let's add this update feature to My Tasks.
Step 3: Detect changes in the My Tasks application cache manifest file
As mentioned before, you'll use the updateready event to detect changes in the ap-
plication manifest. So, all you need to do is define and attach an event handler to the
application cache's updateready event. The event handler will call the application
cache's swapCache method and ask the user for permission to reload the application us-
 
Search WWH ::




Custom Search