HTML and CSS Reference
In-Depth Information
stored is lost (unless the session-restore features of the browser are
enabled). Local storage lasts until your application clears it, or until the
user manually deletes the data, no matter how many times the
browser's closed in the meantime.
One note before we proceed: while the capacity of local and session
storage is much larger than that of cookies, it's still finite, and varies
substantially between browsers. Web storage can be a useful way to
store large amounts of data on the client side but, like all client-side
technologies, you should never rely on it being available all the time.
Putting it all together
Now that the to-do list app is functional, it would be nice to enable it to
work offline. Because the entire thing is self contained—no external
files of any kind, just the single HTML file—you just need an empty
manifest file
CACHE MANIFEST
#v1
and a reference to that manifest in the markup:
<!DOCTYPE HTML>
<html manifest="storage.appcache">
Remember that the file that references the manifest is always cached
and doesn't need to be listed in the manifest file explicitly. If you have a
set of single-page applications on the same site, then they can all refer-
ence this one manifest file and they'll be cached the first time the user
visits them. You can try it for yourself on your local web server with
the example file in ch06/offline-example/local-storage-4.html.
You've learned about a lot of different HTML5 features in
this chapter, but how many of them can you use right now?
Browser compatibility is summarized in the next section.
Search WWH ::




Custom Search