Cookies vs HTML5 Web Storage vs HTML5 IndexedDB


In general cookies in modern websites and web applications are discouraged -- partly because of their size (typically 4KB per cookie), and partly because all cookie data is passed back and forth with every call to the server, even if the data isn't required for that request.

HTML5 Web Storage

Web storage has several advantages: most notably, it is supported by nearly every modern browser. By default, web storage allows you 5-10MB of space to work with, and your data is stored locally on the device rather than passed back-and-forth with each request to the server.

Web storage is useful for storing small amounts of key/value data and preserving functionality online and offline. With web storage, both the keys and values are stored as strings.

HTML5 IndexedDB

If you want to store large amounts of structured data. That’s where HTML5 IndexedDB databases come in. IndexedDB works both online and offline, allowing for client-side storage of large amounts of structured data, in-order key retrieval, searches over the values stored, and the option to store multiple values per key.

With IndexedDB, all calls are asynchronous and all interactions happen within a transaction.

The HTML5 Web SQL technology has been deprecated by W3C and it’s now highly recommended that developers avoid that technology because browser vendors are not encouraged to support it. IndexedDB is the recommended alternative.

The specification for IndexedDB includes a section on synchronous calls, originally intended for use within HTML5 Web Workers, but that section of the specification might be removed in the future because no browsers currently support synchronous calls.

Popular posts from this blog

How to delete / clear queue of PowerMTA