Storage Quota and Usage Analysis
You'll learn how to monitor how much storage your web app consumes and understand browser-imposed limits before users lose data.
The Storage Budget Problem
Every website gets a "storage budget" from the browser—a maximum amount of disk space it can use across localStorage, IndexedDB, Cache Storage, and other storage mechanisms. This quota is per-origin (protocol + domain + port), not global. If your site exceeds its quota, new writes fail or old data gets evicted, breaking your app.
Think of it like a bank account: you need to know your balance before writing checks, or they'll bounce.
Viewing Storage Usage in DevTools
The Application panel provides a Storage section (often at the bottom of the left sidebar) showing:
- Usage: How many bytes your origin currently consumes
- Quota: The maximum allowed storage (varies by device, available disk space, and browser)
- Breakdown by type: How much localStorage, IndexedDB, Cache Storage, etc. each contribute
Some browsers show a visual meter (like "5.2 MB used of 300 MB available"). This lets you see if you're approaching limits.
Understanding Eviction Policies
Browsers use two storage categories:
- Persistent: Explicitly requested storage that won't be evicted without user permission (via
navigator.storage.persist()) - Best-effort: Default storage that browsers may delete under disk pressure (low space, LRU eviction)
Most web apps use best-effort storage by default. Critical apps (like offline-first note-taking) should request persistent storage and check quota regularly:
// Check quota programmatically (we've covered navigator APIs conceptually)
if (navigator.storage && navigator.storage.estimate) {
navigator.storage.estimate().then(({usage, quota}) => {
console.log(`Using ${usage} of ${quota} bytes`);
});
}
Key Takeaway: Always monitor your storage quota in DevTools and programmatically to prevent data loss—browsers will evict data when space runs low, and limits vary wildly across devices.