What is IndexedDB and how is it used by PWA?

Technology CommunityCategory: PWAWhat is IndexedDB and how is it used by PWA?
VietMX Staff asked 5 months ago

IndexedDB is a large-scale, NoSQL storage system. It lets you store just about anything in the user’s browser. In addition to the usual search, get, and put actions, IndexedDB also supports transactions.

IndexedDB is a low-level API for client-side storage of significant amounts of structured data, including files/blobs. This API uses indexes to enable high performance searches of this data. While DOM Storage is useful for storing smaller amounts of data, it is less useful for storing larger amounts of structured data. IndexedDB provides a solution.

In a context of PWA a general recommendation for storing data offline:

  • For the network resources necessary to load your app while offline, use the Cache API (part of service workers).
  • For all other data, use IndexedDB (with a promises wrapper).