chrome.storage.local resets after sometime

1,519 views
Skip to first unread message

Uğur

unread,
Nov 2, 2022, 2:09:34 PM11/2/22
to Chromium Extensions
Hi everyone, 

I am working on a project that I set some data in the chrome.storage.local but after some time, it just got deleted.

When chrome becomes inactive, does storage deleted? 

How can I store the data persistently?

I want to delete it manually.

I use this code snippet to delete the storage

if (tabId in cache) {
        delete cache[tabId]
        await Storage.set("cache", cache)
  }

Stefan Van Damme

unread,
Nov 2, 2022, 3:41:56 PM11/2/22
to Chromium Extensions, ugur.kell...@gmail.com
Hi ugur,

When you store data in your chrome.storage.local, it stays there. Even if you close your Chrome web browser or the window becomes inactive. It will not be deleted.

Note: The chrome.storage.local can only store a limited amount. Can you check if the saved data is not higher than this quota bytes:
QUOTA_BYTES 5242880
The maximum amount (in bytes) of data that can be stored in local storage, as measured by the JSON stringification of every value plus every key's length. This value will be ignored if the extension has the unlimitedStorage permission. Updates that would cause this limit to be exceeded fail immediately and set runtime.lastError.

Thanks,
Stefan vd

Reply all
Reply to author
Forward
0 new messages