We are happy to announce that the Storage API feature is ready for testing in Firefox Nightly Desktop!
Storage API
- IndexedDB databases
- Cache API data
- Service Worker registrations
- Web Storage API data
- History state information saved using pushState()
- Notification data
Storage limits
The maximum browser storage space is dynamic — it is based on your hard drive size when Firefox is launching. The global limit is calculated as 50% of free disk space. There’s also another limit called group limit — basically this is defined as 20% of the global limit, to prevent individual sites from using exorbitant amounts of storage where there is a free space, the group limit is set to 2GB (maximum). Each origin is part of a group (group of origins).
Site Storage
<span class="token keyword">
if (navigator.storage && navigator.storage.persist) {
navigator.storage.persist().then(persisted => {
if (persisted)
console.log(“Persistent mode. Quota is bound by global limit (50% of disk space).”);
else
console.log(“Best-effort mode. Storage may be evicted under storage pressure.");
});
}
</span>
- Each example is independent here.
- If a user allows the site to store persistently, the user can store more data into disk, and the site storage quota for origin is not limited by group limit but global limit.
- Site Storage Unit of Origin A consists three different types of storage, IndexedDB Databases, Local Storage, Cache API Data; Site Storage Unit of Origin B consists Cache API Data only. Site Storage Unit of Origin A and Bs’ quota is limited to global limit.
- Site Storage Unit of Origin C is full, it is reached to quota (global limit) and can’t store any data without removing existed site storage data. UA will start to evict “best-effort” site storage units under a least recently used (LRU policy), if all best-effort site storage units are freed but still not enough, the user agent will send storage pressure notification to clear storage explicitly. See below thex storage pressure notification screenshot. Firefox may notify users when data usage is more than 90% of global limit to clear storage.
- Site Storage Unit of Origin D is also full, the box mode is “best-effort”, so quota is storage limit per origin (Firefox 56 is still bound by group limit), and best-effort mode is smaller than persistent storage. User agent will try to retain the data contained in the box for as long as it can, but will not warn users if storage space runs low and it becomes necessary to clear the box to relieve the storage pressure.
<span class="token keyword"> </span>
If user “persist” the site, that site data of that origin won’t be evicted until the user manually delete them in Preferences. With the new ‘Site Data Manager’, the user now can manage site data easily and delete persistent site data manually in the same place. Although cookies are not part of Site Storage, Site Storage should be cleared along with cookies to prevent user tracking or data inconsistency.
Storage API is now available for testing in Firefox Nightly 56.
What’s currently supported
- navigator.storage.estimate()
- navigator.storage.persist()
- navigator.storage.persisted()
- new Site Data Manager in Preferences
- IndexedDB, asm.js caching, Cache API data are managed by Storage API
Storage API V1.5
- Local Storage/History state information/Notification data are managed by Storage API
Storage API V2
- Multiple Boxes
Try it Out
Take a look at the Storage api wiki page for much more information and to get involved.
No comments yet
Post a comment