LocalStorage QuotaExceededError behavior across browser engines
0 reputation · 18 Dec 2021, 23:04 UTC
The HTML5 LocalStorage API provides a synchronous key-value store for persisting string data per origin. While most modern browsers implement a storage limit of approximately 5MB, the exact threshold and the resulting behavior when this limit is reached can vary.
When a setItem() operation exceeds the available capacity, the browser is expected to throw a QuotaExceededError. However, the precision of this limit and the consistency of the error trigger across different browser engines remain a point of uncertainty for applications requiring strict storage budget management.
- Is the 5MB limit calculated based on the number of characters or the actual byte size of the UTF-16 strings?
- Do different browser engines handle the
QuotaExceededErrorconsistently when the limit is reached during a sequence of multiple small writes versus one large write?