EN
FRENCH
繁体中文
IndexedDB is a browser API that allows web applications to store large amounts of structured data directly on a user's device.
It provides a client-side database with support for indexes, transactions, and asynchronous operations. IndexedDB is commonly used for offline applications, caching, and storing application data.
Also known as: IDB, browser database, client-side database.
IndexedDB stores information in databases containing collections called object stores.
A typical workflow includes:
Unlike traditional server databases, IndexedDB runs within the browser environment.
Both IndexedDB and localStorage store data in the browser, but they serve different purposes.
IndexedDB is more suitable for complex applications, while localStorage is useful for small amounts of simple data.
IndexedDB and Service Workers often work together in offline web applications.
For example, a Service Worker can retrieve previously stored data from IndexedDB when an application is offline.
The main difference is where the information is stored.
IndexedDB enables offline access, but locally stored data is not automatically synchronized between devices.
Some websites store application data in IndexedDB instead of requesting it from the server every time.
This can affect browser-based data collection because information displayed on a page may come from local storage.
A headless browser can inspect IndexedDB when necessary, while a basic HTTP client cannot directly access a browser's local database.
Suppose a shopping application wants to save product information for offline browsing.
It can use IndexedDB to store records such as:
{
"id": 1001,
"name": "Wireless Mouse",
"price": 29.99,
"availability": true
}
When the user loses internet connectivity, the application can retrieve previously saved product information from IndexedDB.
Once connectivity returns, the application may synchronize updated information with its server.
IndexedDB is a browser-based database API designed for storing structured information locally.
It supports indexes, transactions, asynchronous access, and offline functionality, making it useful for modern web applications. Compared with localStorage, IndexedDB is better suited for larger and more complex datasets.
Partenariat