Open hanguokai opened 1 year ago
Here is a new article from Chrome about this topic: Storage and cookies in extensions. The article states that:
By default, extensions are subject to the normal quota restrictions on storage, which can be checked by calling navigator.storage.estimate(). Storage can also be evicted under heavy memory pressure, although this is rare. To avoid this:
- Request the "unlimitedStorage" permission, which affects both extension and web storage APIs and exempts extensions from both quota restrictions and eviction.
- Call navigator.storage.persist() for protection against eviction.
I will update my original table.
Peter Coles asked a question[^1] in Chrome extension forum. I rearrange it and post it here.
Here I use "Web Storage" to represent all standards web storages, including Local Storage, Cache Storage, IndexedDB, OPFS, etc.
Quota and Eviction
Web Storage has the limitation of quotas and eviction and related API like
StorageManager.persist()
andStorageManager.estimate()
.Should Web Storage in extensions be protected? Ideally, it should be treated as unlimited and not be evicted by default, i.e.
navigator.storage.persisted()
returntrue
, like PWA installed Web apps."unlimitedStorage" permission
Another orthogonal issue is "unlimitedStorage" extension permission.
[^1]: Web storage eviction question by Peter Coles [^2]: Chromium issue 680392. [^3]: Chromium issue 1209236. [^4]: MDN storage.local [^5]: Safari unlimitedStorage