HTML and CSS Reference
In-Depth Information
(which has been stored offline).
With this in place you should be able to reload the tasks.html page, which in turn will en-
sure the revised version of the manifest will be loaded. You should then be able to shut-
down the web server, and hit reload, and have the page display. Even if you restart Chrome
with the server shutdown, you can still load the tasks.html page.
The final subject we need to address with the Application Cache is how do you reload re-
sources when they are changed? The browser will use the cached versions of files whether
it is online or offline, therefore changing any of the resources in the application will not be
reflected on the client, even if the client has access to the server.
The browser will download fresh copies of resources only when the manifest file itself
changes. This sounds problematic, since you may not have anything you wish to change in
the manifest file, yet still wish to load new versions of the resources. The solution to this is
to add a comment in the manifest file, and change this comment every time the resources
change, for example:
# version 1
Any line starting with a # is a comment, however changes to comments are sufficient to
force the application cache to refresh. We can therefore continue incrementing this version
number each time we want the cache to reload the resources.
If you save this change and reload the page, Chrome should inform you that the cache has
an “last update time” of now, even though the “creation time” is in the past:
If you have the console open you will also see the resources being downloaded.
Many features of the Application Cache API seem counter-intuitive. A further aspect that
may surprise you about the update process is that the user will not see any updated re-
sources the first time they load the page. The way the application cache works is to first
present the user with the web page (using the cached version of resources), and then begin
updating and storing the new version of the application in the app cache. It is not therefore
until the second time the user loads the page that they will see any updated content.
Search WWH ::




Custom Search