What happens if a user disables storage or clears site data?
Ask by ICSM Computer
Updated 04 Jul 2025
When a user disables storage or clears site data, your IndexedDB data can be lost or made inaccessible, depending on the action and browser.
Here’s a breakdown of what happens:
1. User Clears Site Data (via browser settings)
When a user clears site data (cookies, local storage, cache, etc.), this typically includes:
Impact on IndexedDB:
All databases and object stores are deleted
indexedDB.open()will behave like the DB never existed (i.e., version = 0)onupgradeneeded2. User Disables Storage (Privacy/Incognito Mode)
Some browsers (especially Safari) restrict or block IndexedDB in private mode:
Impact:
indexedDB.open()may:QuotaExceededErrorundefinedor null3. Automatic Eviction by the Browser
Browsers may automatically delete data when:
To reduce risk:
You can request persistent storage (only works in supported browsers):
Best Practices to Handle This
if (!window.indexedDB))onerroronopen,get,putonupgradeneededto recreate schema if DB is gonenavigator.storage.persist()Detect if Data is Lost
Summary