Home
← All questions

Browser storage quotas and eviction | Web Fundamentals

MediumPremiumWeb Fundamentals

Asked at Google · Apple · Meta

Web Fundamentals interview practice: Compare localStorage, sessionStorage, IndexedDB limits and eviction policies.

Answer

Browsers persist data per origin with very different semantics:

APICapacityPersistenceSync
localStorage~5 MB (varies)Until clearedSynchronous, main thread
sessionStorageSame tab sessionTab lifetimeSynchronous
IndexedDBLarge (often 50%+ disk)Until evictedAsync
Cache APIPart of origin quotaSW-managedAsync

Eviction: under storage pressure browsers use LRU heuristics — origins without recent user interaction may be cleared first. Safari ITP is aggressive with third-party and cross-site storage.

Best practice: use IndexedDB (via Dexie/idb) for structured/large data; never block main thread with sync storage.

Premium question

Unlock the full model answer with Mentoxis Premium.

Unlock with Premium