PoolByte

IndexedDB: Local Data, Schema Changes and Quotas

· PoolByte Technology

IndexedDB: Local Data, Schema Changes and Quotas

Keeping a few settings in the browser is different from keeping a large catalogue, drawing sketch or set of editable records. IndexedDB is a native database interface that works asynchronously on structured data. It is not an automatic copy or permanent backup of the database on the server.

When should it be evaluated?

If there is a need to search by fields in large data sets, update separate records, or execute related changes together, IndexedDB can be considered. For small preference values, a simpler storage method may be sufficient. Determine from the beginning why you put the data in the browser and how you will retrieve it.

MDN IndexedDB guide describes basic structures such as object stores, indexes, and transactions. Asynchronous behavior also affects when the “saved” status is shown on the screen. Initiating the write request and successfully completing the operation are not the same moment.

The local schema is also versioned

The record structure may change in the new version of the application. Plan how you will move the old browser data to the new format. If the same app is open in two tabs, the old connection may block the upgrade, or the old tab may operate with assumptions that are no longer valid. Show the user a clear status for refreshing the tab or completing their action.

For example, a quote preparation tool adds a new currency field. Upgrading without determining what value older drafts will receive may result in misinterpretation of amounts. Deleting local records in bulk is an easy development solution; It may not be acceptable for the client to lose drafts that have not yet been sent to the server. Test the migration with real old version data.

Quota and possibility of deletion

Browsers impose different limits and eviction policies for storage. MDN storage quota description describes the conditions for these behaviors. The user may clear the site data or space pressure on the device may affect the data. Don't promise local data will "never disappear."

The application should not show success notification in case of write error or quota reached. Consider appropriate recovery paths, such as exporting the draft or saving it to the server. Also try private mode, closed storage and corrupted save cases. The absence of browser data does not mean that the account's data on the server has been deleted; messages should separate this.

Cross-account data limit

When a customer logs out and another logs in on a shared device, the previous person's drafts should not appear. Associate the local record scope with the account and define the sign-out cleanup policy. Do not consider sensitive data safe just because it remains in the browser; Access risks of the code running on the page are also evaluated.

Add concurrent tab, failed write, legacy schema, and account switch to the test plan. In PWA design IndexedDB is just the data layer when planning offline experience. A solid product accurately tells the user when the local record is trusted and at what point it is finalized with the server.