IndexedDB pulls away from less-loved web storage options

IndexedDB API 2.0 spec has reached draft form. Contain yourself, and your data


The Indexed Database API 2.0 has arrived in draft form, promising a variety of improvements in the way developers of web applications can store data in browsers.

IndexedDB is a JavaScript-based object-oriented database within modern browsers. It began taking shape in 2011 and, after years in draft form, it met with W3C approval last year.

It's particularly useful for web applications that need to store large amounts of data to function offline, and for Progressive Web Apps. Now there's a second version under consideration.

IndexedDB is one of several client-side storage options for web apps. Other options include:

  • Cookies, which are limited in size and data type, and don't support recent APIs like Web Workers.
  • DOM Storage, which has similar limitations.
  • WebSQL, a one-time challenger that has been deprecated.
  • AppCache, characterized as a "douchebag" for being difficult to use.
  • The Cache API, intended for URL-addressable resources and not available in all browsers.
  • The File API, which isn't yet fully baked.
  • The Chrome-only FileSystem API.

Unlike Cookies and DOM Storage, IndexedDB works asynchronously, so its operations do not block other operations while active. Although broad support for IndexedDB has been slow in coming – Apple just recently implemented full support in Safari 10 – it's now a worthy choice for storing significant amounts of structured data in the browser.

In a blog post on Tuesday, Bevis Tseng, a platform engineer at Mozilla, highlighted some of the new capabilities coming to IndexedDB in Firefox 51, available for developers now and scheduled for the general public in January 2017.

The IndexedDB API 2.0 offers a setter to rename existing object stores and indexes, via IDBObjectStore.name and IDBIndex.name.

It also provides a way to listen for storage change events through the IDBDatabase.onclose() event handler.

The updated API also adds support for binary data types as index keys. "Now you can have binary signatures as keys directly, without serializing them into strings or array objects as required by the previous API version," explained Tseng.

And a variety of other methods have been added that improve how database keys can be accessed, such as IDBObjectStore.getKey(query), IDBObjectStore.openKeyCursor(range, direction),and getAll/getAllKeys(range, count).

IndexedDB doesn't yet support JavaScript Promises – a way to deal with events that may succeed or fail while running asynchronous code – but there's a proposal and there are libraries that provide support. For those who have to store client-side data in web apps, IndexedDB is worth a look. ®

Narrower topics


Other stories you might like

  • US won’t prosecute ‘good faith’ security researchers under CFAA
    Well, that clears things up? Maybe not.

    The US Justice Department has directed prosecutors not to charge "good-faith security researchers" with violating the Computer Fraud and Abuse Act (CFAA) if their reasons for hacking are ethical — things like bug hunting, responsible vulnerability disclosure, or above-board penetration testing.

    Good-faith, according to the policy [PDF], means using a computer "solely for purposes of good-faith testing, investigation, and/or correction of a security flaw or vulnerability."

    Additionally, this activity must be "carried out in a manner designed to avoid any harm to individuals or the public, and where the information derived from the activity is used primarily to promote the security or safety of the class of devices, machines, or online services to which the accessed computer belongs, or those who use such devices, machines, or online services."

    Continue reading
  • Intel plans immersion lab to chill its power-hungry chips
    AI chips are sucking down 600W+ and the solution could be to drown them.

    Intel this week unveiled a $700 million sustainability initiative to try innovative liquid and immersion cooling technologies to the datacenter.

    The project will see Intel construct a 200,000-square-foot "mega lab" approximately 20 miles west of Portland at its Hillsboro campus, where the chipmaker will qualify, test, and demo its expansive — and power hungry — datacenter portfolio using a variety of cooling tech.

    Alongside the lab, the x86 giant unveiled an open reference design for immersion cooling systems for its chips that is being developed by Intel Taiwan. The chip giant is hoping to bring other Taiwanese manufacturers into the fold and it'll then be rolled out globally.

    Continue reading
  • US recovers a record $15m from the 3ve ad-fraud crew
    Swiss banks cough up around half of the proceeds of crime

    The US government has recovered over $15 million in proceeds from the 3ve digital advertising fraud operation that cost businesses more than $29 million for ads that were never viewed.

    "This forfeiture is the largest international cybercrime recovery in the history of the Eastern District of New York," US Attorney Breon Peace said in a statement

    The action, Peace added, "sends a powerful message to those involved in cyber fraud that there are no boundaries to prosecuting these bad actors and locating their ill-gotten assets wherever they are in the world."

    Continue reading

Biting the hand that feeds IT © 1998–2022