Storage Quotas and Eviction: The Physics of Browser Data

Storage Quotas and Eviction: The Physics of Browser Data

By default, the browser can delete your stored data without asking, and Safari deletes script-writable data after seven days of Safari use with no interaction on the site (a home screen web app's first-party domain is exempt). The eviction rules and the design discipline that survives them.

Everything a web page stores on the device is best-effort by default — the browser may delete it under storage pressure without asking, Safari deletes script-writable storage after seven days of Safari use without user interaction on the site (a home screen web app's first-party domain is exempt), and quota is an estimate rather than a promise. This guide sets out the general rules for when the browser is allowed to take your data back, and the design discipline — classify, persist, and detect the wipe on startup — that keeps that from becoming a broken user experience.

Best-effort by default

A fact about client-side storage that server engineers have to un-learn: what you write is not guaranteed to stay written. Everything script-writable — IndexedDB databases, localStorage entries, Cache API responses, OPFS files, even service-worker registrations — is stored on a best-effort basis by default. Under storage pressure the browser may delete an origin's best-effort data to reclaim space, without asking the user. Do not count on your application hearing about it: the Storage Standard says browsers should avoid clearing a bucket while script that can access it is running, unless the user instructs otherwise, so plan to discover an eviction on the next start (an IndexedDB connection that is open when its storage is cleared does receive a close event).

The mental model that reframes every downstream decision is that storage is a lease, not a deed. You are not the owner of that disk space; you are a tenant whose lease the browser can end when the building needs the room. Build on that assumption and eviction is an expected state you handle. Build on the server-storage assumption and eviction is a production incident you did not see coming.

It also helps to count the actors who can delete your data, because there are three and your app can only influence one of them. The browser evicts under pressure by its own logic. The user clears browsing data whenever they choose. And at the operating system level, a device reset or a deleted browser profile removes the data entirely outside the browser's control. Persistence requests, which we come to below, speak only to the first actor. Nothing you write in JavaScript stops the second or the third, so the design has to assume all three.

How much space you actually have

Quota is origin-scoped and set by browser-specific rules. The Storage Standard says quota must not be a function of the device's available storage space, and the Firefox, Chromium, and WebKit (macOS 14 and iOS 17 onward) rules described on MDN are based on total disk size rather than free space. That makes the only honest general statement "it varies by browser, device, and disk." Resist every source that quotes a fixed number or a clean percentage; those figures drift between versions and depend on hardware you do not control (check MDN's current quota criteria before relying on one; as of Nov 2026).

The platform gives you an estimate, not a guarantee. navigator.storage.estimate() returns the origin's approximate usage and quota, and in some browsers the numbers are deliberately fuzzed to resist fingerprinting. It is useful for a rough "are we near the ceiling" check and useless as a promise of writable headroom.

js
const { usage, quota } = await navigator.storage.estimate();
// Both are estimates — never a guarantee that (quota - usage) bytes will write.

Because the estimate cannot be trusted as headroom, the runtime truth arrives as an error you must expect. A write that exceeds available space throws QuotaExceededError, and code that treats it as an exception that never happens will fail exactly when a user's disk is full — the worst moment to discover you had no handling path. In IndexedDB the error is reported when the transaction commits, as an abort with QuotaExceededError as the transaction's error, so catch it on the transaction rather than on the individual put().

js
try {
  const tx = db.transaction('records', 'readwrite');
  tx.objectStore('records').put(record);
  await tx.done; // idb wrapper: rejects with the transaction's error. With the raw API, handle the transaction's abort event.
} catch (err) {
  if (err.name === 'QuotaExceededError') {
    // Expected path: shed re-fetchable cache, surface a clear state, do not lose user work.
  } else {
    throw err;
  }
}

One environment is easy to miss in testing: private or incognito windows may apply different quotas, and their stored data is usually deleted when the private browsing session ends. A feature that works on every developer's machine can fail for a user in a private window.

Eviction: when it happens and what goes

When the browser does evict, two patterns matter for design. Eviction is typically least-recently-used across origins — the sites a user has not visited lately go first — and it typically takes an origin's whole bucket at once rather than trimming a few records. You should not design as if some of your data will survive a partial eviction; assume it is all there or all gone.

Safari adds a second, time-based rule on top of pressure-based eviction — counted in days of Safari use, not calendar days — and it is a consequential rule for any data layer meant to persist. Under Intelligent Tracking Prevention, all script-writable storage is capped at seven days of Safari use without the user interacting with the site (in effect since Safari 13.1 / iOS 13.4, per webkit.org; still WebKit's documented rule as of Nov 2026). Two caveats matter as much as the rule itself: the seven-day counter restarts when the user interacts with the site (a click, tap, or keyboard entry; scrolling does not count), so an actively used app is far less exposed than a rarely opened one, and the first-party domain of a web app saved to the home screen is exempt from the seven-day deletion (per WebKit's tracking-prevention documentation, as of Nov 2026). State the rule, apply the caveats, and engineer for it — do not build a mental model on the headline alone.

Firefox and Chromium differ from Safari and from each other in the fine detail of when eviction fires and what triggers it. Chasing every per-browser nuance is a losing game; the craft is designing so that the differences do not matter, because your data layer already assumes it can be wiped between any two visits.

Persistence: asking to keep it

There is one lever that speaks to the browser's own eviction logic, and it is a request rather than a right. navigator.storage.persist() asks to upgrade the origin's storage from best-effort to persistent — exempt from automatic eviction under pressure, though never exempt from the user clearing data themselves.

js
if (navigator.storage?.persist) {
  const granted = await navigator.storage.persist(); // may return false — handle it as normal
}

Grant behavior diverges by browser: some decide silently on engagement heuristics (has the user installed the app, do they visit often), and others prompt the user directly (as of Nov 2026; per-browser behavior is worth re-verifying, since it shifts). Your code must treat a false return as an ordinary outcome, not an error. navigator.storage.persisted() checks the current state without requesting. As for timing, web.dev recommends requesting persistence when the user saves critical data, ideally inside a user gesture, and not on page load — in a browser that prompts, a request the user sees no reason for is likely to be rejected.

One adjacent capability deserves exactly one sentence of acknowledgment: the Storage Buckets API lets an origin split its storage into buckets with independent eviction priorities, but it is Chromium-only and still incubating in the WICG (Chromium 122+, as of Nov 2026), so a cross-browser data layer can note it exists and must not lean on it.

Designing for eviction

All of the physics resolves into one design discipline, and it is worth stating as the rule this whole article exists to deliver: classify every piece of stored data into one of three classes.

Re-fetchable data lives on the server and is merely cached locally for speed — cache it freely, because losing it costs a round-trip and nothing more. Reconstructible data can be derived again at some cost — cache it, but keep a rebuild path so eviction means a delay rather than a loss. Unrecoverable data exists only on this device — a draft the user typed, a mutation queued while offline — and it must be synced off the device or made explicitly exportable, because best-effort data is not guaranteed to stay: per MDN, it persists as long as the origin is below its quota, the device has enough storage space, and the user does not choose to delete it through the browser's settings — and the other deletion paths described above, such as Safari's seven-day rule, can remove it even when all three hold. The corollary is the sentence to tattoo onto the design: never let unrecoverable data accumulate in best-effort storage. The write-queue and sync articles exist precisely because of this class of data.

The classification implies a concrete startup pattern. Because the browser can wipe your storage between any two visits, the app has to detect the evicted-while-away state on load and route to a rebuild rather than crashing on data it assumed was present. In practice that means checking for the signatures of an eviction — a schema present but its records gone, a version stamp missing, an expected key absent — and treating "empty" as a first-run rebuild path rather than an error.

js
// On startup: distinguish "evicted while away" from a healthy store, and rebuild rather than crash.
const db = await openDatabase();
const stamp = await db.get('meta', 'schemaVersion');
if (!stamp) {
  // Storage was wiped or never initialized — reconstruct from server, do not assume records exist.
  await rebuildFromServer(db);
}

Reproducing eviction and quota exhaustion deliberately — filling storage until the browser evicts, simulating the Safari clock — is the storage-debugging article's territory, noted here in one deferring sentence. The point of this article is upstream of the tooling: once you have internalized that storage is a lease, that three actors can end it, and that unrecoverable data must never live only on the device, the physics stops being a source of mysterious field bugs and becomes a set of constraints you designed for on purpose.

Project Inquiry