IN-DEPTH GUIDE // WEB STORAGE ARCHITECTURES: LOCALSTORAGE, SESSIONSTORAGE & INDEXEDDB
Understanding browser origin quotas, key-value serialization, persistence lifecycles, and client security considerations.
Comparing Browser Storage Engines
Web browsers provide distinct client-side storage mechanisms designed for specific persistence and data structure requirements:
- localStorage: Synchronous key-value storage that persists indefinitely across browser restarts until explicitly cleared by user or script. Typically capped at 5 MB per origin.
- sessionStorage: Identical synchronous key-value API to localStorage, but scoped strictly to a single browser tab lifetime. Closing the tab immediately destroys the storage.
- IndexedDB: Asynchronous, transactional object-oriented database supporting indexes, binary blobs, and massive storage quotas (often gigabytes based on available disk space).
Security & Cache Hygiene
Because localStorage and sessionStorage are accessible to any JavaScript executing within the origin, storing sensitive secrets (such as unencrypted JWT private keys or passwords) is an anti-pattern vulnerable to Cross-Site Scripting (XSS).
Cache Scrubber empowers engineers to audit all keys stored under the current origin, prune orphan telemetry caches, and inspect structured JSON data without opening browser developer tools.
Frequently Asked Questions
Can this tool read storage from other websites?
No. Browsers enforce the strict Same-Origin Policy (SOP). A web page can only inspect and modify storage belonging to its exact protocol, hostname, and port.
How is byte consumption calculated?
JavaScript strings are encoded as UTF-16, with standard ASCII consuming 1 byte in memory or 2 bytes per character under complete UTF-16 representation. Total length of keys plus values is calculated in real time.
What happens if storage exceeds 5 MB?
Attempting to call localStorage.setItem() beyond origin quota raises a QuotaExceededError DOMException, halting further writes.
Does clearing storage affect my other browser tabs?
Clearing localStorage updates all tabs sharing the current origin simultaneously via the storage window event.