What’s New
- The Synchronous FileSystem API for Workers
- Exploring the FileSystem APIs
- A Simple TODO list using HTML5 IndexedDB
- Web SQL Database - Async Transactions
- Quota API - Show usage and quota request
- Web Storage - sessionStorage
- Web Storage - localStorage
- Client-Side Storage
- 4-part tutorial on Web Storage
- Firefox 4: An early walk-through of IndexedDB
Offline Technologies
- Web Storage simply provides a key-value mapping, e.g.
localStorage["name"] = username;. Unfortunately, present implementations only support string-to-string mappings, so you need to serialise and de-serialise other data structures. You can do so usingJSON.stringify()andJSON.parse(). - Web SQL Database gives you all the power - and effort - of a structured SQL relational database.
- Indexed Database is somewhere in between Web Storage and Web SQL Database. Like Web Storage, it's a straightforward key-value mapping, but it supports indexes like those of relational databases, so searching objects matching a particular field is fast; you don't have to manually iterate through every object in the store.
- File Access is an API for reading file content in JavaScript. Given a set of files the user has added to a "file" input element, you can read the content of the file or reference it as a URL, e.g. if the user has specified an image file, you can show the image. There are also proposals underway for file writing capabilities.
For a detailed comparison of client-side storage techniques with code demos, see our Client-Side Storage article.
Demos
In the Wild
Resources
- Dive into HTML5: Storage Mark Pilgrim dives into using the storage APIs.
- MDC: DOM Storage Mozilla Developer Center on Web Storage.
- MDC: IndexedDB Mozilla Developer Center on IndexedDB.
- Mozilla Hacks: offline web applications Creating a todo list manager using localStorage, app cache and offline events.
- Beyond HTML5: Database APIs and the Road to IndexedDB Mozilla explains its views on Web SQL Database and Indexed Database