HTML and CSS Reference
In-Depth Information
Applications executing in the
appcache
context are not allowed to con-
nect to remote URLs unless those URLs are listed within the
NETWORK
section of the manifest. This is to provide an additional layer of security
to applications, preventing them from contacting servers that aren't
known and whitelisted.
Once you have the manifest file—in this example we've named it
cache.manifest
—tell
the browser about the file by adding a property to the
html
element in your markup,
like so:
<html
manifest="cache.manifest"
>
The cache manifest file must be served with the MIME type
text/cache-
manifest
.
That's it! Now your application is offline-capable via
appcache
. The browser persistently
caches the listed resources and does not re-request them on subsequent page loads,
unless the cache manifest file changes.
Updating the appcache
Simply changing a file that is stored in a user's
appcache
is
not
enough to get that new
version of the file delivered to the user. The browser will only check for updated versions
of files in its
appcache
(and subsequently download any changes) if the manifest file
changes.
However, you may not have any changes to make to the manifest file itself if, for ex-
ample, there are no new resources to list and none to remove.
So, one easy approach is to include in your file a comment that you can update with a
new value whenever you change one or more files and want the browser to update its
appcache
:
CACHE MANIFEST
# cache version: 1257
CACHE:
index.html
help.html
style/default.css
images/logo.png
images/backgound.png
Each time you update a resource that is in the
appcache
, simply bump up the version
number in the comment. The next time a user loads the page, the browser will see this
new cache manifest file and update the
appcache
contents.
