Reputation: 79
I'm developing a Chrome extension and using old localStorage to store settings and cache instead of new chrome.storage.local
and chrome.storage.sync
. I have unlimitedStorage
permission and then my cache becomes huge. I'm receiving QuotaExceededError
.
How to overcome the problem?
Upvotes: 2
Views: 2853
Reputation: 33306
localStorage
is not, and will not be, unlimitedThe fact that the unlimitedStorage
permission does not apply to localStorage
is stated in the documentation. The referenced bug, issue 58985, was marked as "WontFix" in December of 2010. Thus, there is not, and will not be, a solution for you to store unlimited data in localStorage
. You will need to select some other method of storing your data.
storage.local
Your options include chrome.storage
which is explicitly intended for extensions to store data. You can store data that is local to the machine, using storage.local
(can be unlimited with the unlimitedStorage
permission), or data that is synchronized across the user's Google account, with storage.sync
(quota is not set to unlimited by unlimitedStorage
).
There are other options for storing data. For instance, the Web SQL Database, which is specifically granted unlimited storage by the unlimitedStorage
permission.
The amount of data you can store with the File API becomes unlimited with the unlimitedStorage
permission. You can also separately request a specific quota size with a call to webkitStorageInfo.requestQuota()
, without using the unlimitedStorage
permission. When you do, the user will be asked to approve the storage request. If you do use the unlimitedStorage
permission, you do not need to separately request a quota.
What is best to use will depend on exactly what you are using storage for. You have provided no information as to your actual use, so there is no way for us to gauge what might be a good fit in your case.
As to your issue with the application cache growing to a large size with the unlimitedStorage
permission: Yes, the documenation explicitly states that declaring the unlimitedStorage
permission will result in the application cache becoming unlimited. If this is an issue, you will need to not declare the unlimitedStorage
permission.
Upvotes: 5