The granary’s seal: the real persist() and estimate() in this browser, then a simulated full disk: what does the browser clear, and which origin goes first?…
Why it matters
An offline app keeps drafts, photos or a queue in the browser, then one day the data is gone though nothing deleted it. Not a bug in your code: the user’s disk was full and best-effort origins were cleared. Knowing when browser data can be trusted, and when it needs a backup on a server, starts here.
The key idea
Best-effort goes whole, the longest unopened first
Common mistakes
Thinking IndexedDB and cache data are permanent on their own The default is best-effort: the browser may clear it when the disk is full, without asking. For important data, ask for navigator.storage.persist() and still back it up to a server.
Thinking persist() is always granted The browser decides, and false is not an error. Chrome and Edge grant sites that are used a lot (a bookmark, installed as an app, notification permission), Firefox asks the user. Check navigator.storage.persisted() to know the state.
Confused why a smaller origin was removed first The order follows the last visit (the longest unopened first), and an origin goes whole. The size of its data does not set its turn; persistent origins are passed over.
Try it in this playground
Call the real persist() Its answer comes from this browser, true or false.
Measure usage before and after storing It rarely grows by exactly the body’s size.
See this site cleared whole Its jars, drawers and caches go at once.
Open an origin, then run again It moves to the end of the line.