HTML and CSS Reference
In-Depth Information
}, false);
Typically, you would wire up such a check to happen either on an automatic time
interval, such as every 24 hours, or in response to a specific application action, such as
the user clicking a button in your page.
If you perform appcache updates at an automatic time interval, prompt-
ing the user before a reload is probably the friendliest approach. How-
ever, if the user initiates the update you can probably safely reload the
page without prompting, as soon as the appcache is updated.
We mentioned that the appcache is special, and the reason for that assertion is that,
unlike with the browser cache, resources that are in the appcache never expire (this is
similar to the localStorage interface we discussed in Recipe 10.1 ).
Practically speaking, this means any resources listed in the cache manifest are cached
permanently. More specifically, the browser does not re-request any of those resources
on subsequent page loads.
The persistent caching of resources definitely improves performance on subsequent
page views, especially on bandwidth-limited mobile devices. However, it's sometimes
necessary to be able to update one or more items in that persistent cache.
There are two ways to go about forcing the browser to discard its cache and update the
resources listed in the manifest. One technique is useful for subsequent page loads,
while the other is useful for updates during the lifetime of a single page view.
It's important to understand that if an appcache already exists for a page at the time of
page load, even if it's determined to be out of date by virtue of finding an updated cache
manifest file, the browser still uses the current appcache to render the page; any updates
to the appcache contents are available only on the next page load.
However, using JavaScript via the UPDATEREADY event, as shown above, you can detect
that the current page was rendered with out-of-date cache items and force an update
of the appcache during that page view. This allows any subsequent uses of resources in
the page lifetime to use the updated versions of the files. You can also just reload the
entire page to use the new appcache contents everywhere, as long as this is okay with
the user.
The appcache is considered to be more reliable for offline application resource caching
than the normal browser cache. It also provides a JavaScript API for interacting with
updates—something the regular browser cache doesn't provide.
Search WWH ::

Custom Search