Browser Database IndexedDB (1) Overview

IndexedDB is a local database provided by the browser, which can be created and manipulated by web scripts.

background

With the continuous enhancement of browser functions, more and more websites have begun to consider storing a large amount of data on the client side, which can reduce the need to obtain data from the server and obtain data directly from the local.

Existing browser data storage solutions are not suitable for storing large amounts of data: the size of cookies is no more than 4KB, and each request is sent back to the server; Provides a search function and cannot create a custom index. So, a new solution was needed, and this is the background in which IndexedDB was born.

We can view the stored data in IndexedDB through developer tools:

v2-016915ff7e8bf41ca4f0fe656c8ce63e_720w

Features

In layman’s terms, IndexedDB is a local database provided by the browser, which can be created and manipulated by web scripts. IndexedDB allows storing large amounts of data, provides a lookup interface, and can create indexes. These are not available in LocalStorage. In terms of database type, IndexedDB is not a relational database (does not support SQL query statements), and is closer to a NoSQL database.

IndexedDB has the following characteristics:

(1) Key-value pair storage. IndexedDB uses an object store to store data internally. All types of data can be stored directly, including JavaScript objects. In the object warehouse, data is stored in the form of “key-value pairs”. Each data record has a corresponding primary key. The primary key is unique and cannot be repeated, otherwise an error will be thrown.

(2) Asynchronous. IndexedDB does not lock the browser when operating, and users can still perform other operations, which is in contrast to LocalStorage, which operates synchronously. Asynchronous design is to prevent the reading and writing of large amounts of data, which slows down the performance of web pages. …

The post browser database IndexedDB(1) overview first appeared on Lenix Blog .

This article is reprinted from https://blog.p2hp.com/archives/9841
This site is for inclusion only, and the copyright belongs to the original author.