HTML and CSS Reference
In-Depth Information
fn(online);
};
// attaching script node trigger the code to run
document.body.appendChild(script);
}
testOnline(function (online) {
if (online) {
applicationCache.update();
} else {
// show users an unobtrusive message that they're
¬ disconnected
}
});
Killing the cache
As I mentioned earlier in this chapter, the browsers get pretty
sticky with the cache. It's easy to get stuck in a cycle where you
can't clear the cache to test a change you've made. So far, the
spec has no method to programmatically clear the cache (for
example, you can't do it from the applicationCache object).
With that in mind, during development I strongly urge you to
avoid using the cache manifest. Make sure your application
development is completely finished, and only then move on to
adding the manifest attribute. That said, once you've got the
cache in place, how do you go about clearing it? Manually.
Upgrading to a new cache should be as simple as changing
the contents of the manifest file. As I said before, you can use
a comment that includes a version number or similar.
What if you want to start again, or what if you want to remove the
manifest attribute all together? You'll only be able to do this dur-
ing development because it requires you to clear the browser's
cache (and depending on the browser, it's tucked away in differ-
ent places). This isn't something you can do programmatically:
only the user of the browser can actively clear their offline cache.
For Safari, you need to empty (or clear) the cache. By cache I
mean anything that's been stored to help your browsing experi-
ence go faster.
NoTE When you clear the
cache, make sure there
aren't any windows still open
with your application that uses
the manifest.
 
 
Search WWH ::




Custom Search