What is the browser database IndexedDB and what can it do? As browsers become more and more powerful, more and more websites begin to consider storing a large amount of data on the client to reduce data acquisition from the server and directly obtain data from the local. Then the browser data base What is IndexedDB and what can it do? Focus on research today The server Let's take a look at the database's micro network, and hope it can be helpful to everyone.

No browser data storage scheme is suitable for storing large amounts of data: the cookie size is no more than 4 KB, and every request is sent back to the server; LocalStorage is between 2.5 and 10 MB (each browser is different), and it does not provide search function, nor can it establish a customized index. Therefore, a new solution is needed, which is the background of the birth of IndexedDB.
In IndexedDB, we can see the stored data through the development tool:
characteristic
Generally speaking, IndexedDB is a local database provided by the browser, and web script can be created and operated. IndexedDB supports the storage of large amounts of data, provides query interfaces, and builds indexes. This is something that LocalStorage does not have. IndexedDB is not a relational database (does not support SQL query statements) in terms of database type, and is close to NoSQL database.
IndexedDB has the following characteristics:
(1) Key value pair storage. IndexedDB uses an object store internally to store data. You can directly store all types of data, including JavaScript objects. In the object warehouse, data is saved in the form of "key value pair". Each data record has a corresponding primary key, which is unique and cannot be repeated, or an error will be thrown.
(2) Asynchronous. The indexedDB operation does not lock the browser, and users can still perform other operations, which is synchronized with the operation of LocalStorage. Asynchronous design is to prevent reading and writing a large amount of data, resulting in slow web page performance.
(3) Support services. IndexedDB supports transactions, which means that in a series of operation steps, when one step fails, the entire transaction is canceled, and the database is rolled back to the state before the transaction occurred, and not only part of the data is rewritten.
(4) IndexedDB has the same origin restriction. Each database creates its domain name accordingly. The page can only access the database under its own domain name, and cannot access cross domain databases.
(5) The storage space of large IndexedDB is much larger than that of LocalStorage, generally no less than 250 MB, or even no upper limit.
(6) Supports binary storage. IndexedDB stores not only strings, but also ArrayBuffer objects and Blob objects.
At present, the use of IndexedDB database can be directly used in the HTTP protocol, while the cacheStorage cache must use the HTTPS protocol. Therefore, from the perspective of application scenarios, the IndexedDB database is quite extensive. Considering that IE10 also supports it, it is almost certain that the application in actual projects will never be a problem.
For example, some infrequently changing structured data in the page can be stored locally using the IndexedDB database to help improve the interactive performance of the page.
Server database: hopechilam.com