Chapter 9 : Offline Storage – When the Lights Go Out

We’ve all been there. You’ve spent 20 minutes perfecting that important e-mail message in your web mail client, you’re finally ready to send it—and boom!—it’s not going anywhere. You
try again, and still nothing. Then you realize that your network connection has dropped, so you don’t have access to the Internet anymore. What do you do? At this point, many of us have attempted to copy and paste the text into a document stored on the computer itself, where it’s comparatively safe. You should be able to retrieve it if you need to restart your browser or, worse still, the system crashes.

This is the problem with most RIAs: they are only as good as the reliability of the network connection and browser in which they are running. We need some way of storing important information on the user’s computer or device if the network connection between the browser and the server becomes unavailable for some reason.

In this chapter, we’ll investigate the methods available to us in different browsers for storing content locally. You’ll see how to use a combination of these methods effectively within your own RIAs to save data, read back data, and delete data, ensuring cross-browser support.

Interested in JavaScript and RIAs?

I wrote a book for web developers building RIAs and web applications who need to be sure they are writing high quality and efficient code whilst constructing advanced user experiences.