Chrome.Storage.Local Persistence

Matt White

all. I've started developing small extensions using Chrome's various API's, and although things are working great, I'm still curious about a few things.

Two questions, if you all wouldn't mind helping me out:

1. Could someone tell me what the limits are to chrome.storage.local's persistence? I've tried various tests on my own, such as storing a few things with chrome.storage.local.set(), clearing all of my browser history, cookies, etc. and then seeing if everything is still there. Often it will still be there, but sometimes I'll check back later and it will be gone. Overall, I have been unable to definitively label what I'm doing that is occasionally clearing the .local data.

2. I've been working mostly with chrome.storage.sync so far, all while not being signed in using Chrome's "Sign in to Chrome" feature. I read on the API page that in the case that .sync is used while Chrome is offline (as well as not logged in, I'm assuming, which is my case), data is stored locally and then sync'ed later on. My main concern is does this mean the data I'm storing using chrome.storage.sync could potentially get erased as the data I'm storing using chrome.storage.local has in the past? One of the main reasons I've been using .sync anyway is because I've never had an experience of data getting erased with it, while I have with .local (as I've described in #1).

Thanks so much! Help me out, please!

Edit: I'm pretty sure the .local clear isn't happening because of me mistakenly removing the extension and then adding it back in. I know that that will clear the .local data (but preserve the .sync).

kalman

I'm the author of that API.

chrome.storage.local shouldn't be disappearing except on uninstallation (which sounds like is your case) or, very rarely, on database corruption (and we've seen this particularly happening on System Restore).

chrome.storage.sync works the same way, except that the merge algorithm it uses may cause data loss if 2 machines make conflicting changes. In your case, this might happen if you sign into the machine which is using chrome.storage.sync. More commonly it will be because one machine is offline while making the change, or perhaps the user managed to simultaneously change data on 2 machines (which is why it's recommended to only change data on user action -- we should document that).

For what it's worth -- and we should document this too -- the merge algorithm is last-change-wins and sync-is-source-of-truth -- but any local key/value pairs added won't be deleted. If you have:

{a:1, b:2} on computer A (signed in and syncing), {b:3, c:4} on computer B (not signed in),

and computer B signs in, after doing a full sync the state of storage on both A and B will end up at {a:1, b:2, c:4} because A's data was already part of sync, this the source of truth, but 'c' didn't exist yet so was added.

In this scenario A will have gotten an onChange event adding 'c', and B will have gotten an onChange event adding 'a' and updating 'b' from 3 to 2.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Chrome.Storage.Local Persistence

From Dev

Local Storage or other data persistence in elm

From Dev

chrome storage local set not setting

From Dev

Saving Array to Chrome Local Storage

From Dev

Using local storage in Chrome as a DB?

From Dev

chrome storage local set not setting

From Dev

Save json to chrome storage / local storage

From Dev

chrome.storage.sync vs chrome.storage.local

From Dev

In what form does Chrome save local storage?

From Dev

Setting a value to chrome.storage.local is not working

From Dev

Chrome Extension: Local Storage, how to export

From Dev

Persistent local storage for both Firefox and Chrome?

From Dev

Adding new objects to chrome local storage

From Dev

Synchronizing sync and local chrome.storage

From Dev

Unable to pass an object to chrome local storage

From Dev

Persistent local storage for both Firefox and Chrome?

From Dev

Chrome Extension: Local Storage, how to export

From Dev

Adding new objects to chrome local storage

From Dev

Synchronizing sync and local chrome.storage

From Dev

Chrome 61: Local Storage Location Changed?

From Dev

Where are cookies and local storage stored for Chrome?

From Dev

Google Chrome extenstion - local storage set and get

From Dev

how to remove the chrome.storage.local

From Dev

Store and retrieve data from local storage using chrome storage API

From Dev

chrome.webRequest redirectUrl with URL Saved in chrome.storage.local

From Dev

chrome extension: switching from localstorage to chrome.storage.local

From Dev

chrome.storage.local strange behaviour: confused by a duplicate object

From Dev

chrome local storage async pass data to callback properly

From Dev

uploading file from local storage to server with a chrome extension

Related Related

  1. 1

    Chrome.Storage.Local Persistence

  2. 2

    Local Storage or other data persistence in elm

  3. 3

    chrome storage local set not setting

  4. 4

    Saving Array to Chrome Local Storage

  5. 5

    Using local storage in Chrome as a DB?

  6. 6

    chrome storage local set not setting

  7. 7

    Save json to chrome storage / local storage

  8. 8

    chrome.storage.sync vs chrome.storage.local

  9. 9

    In what form does Chrome save local storage?

  10. 10

    Setting a value to chrome.storage.local is not working

  11. 11

    Chrome Extension: Local Storage, how to export

  12. 12

    Persistent local storage for both Firefox and Chrome?

  13. 13

    Adding new objects to chrome local storage

  14. 14

    Synchronizing sync and local chrome.storage

  15. 15

    Unable to pass an object to chrome local storage

  16. 16

    Persistent local storage for both Firefox and Chrome?

  17. 17

    Chrome Extension: Local Storage, how to export

  18. 18

    Adding new objects to chrome local storage

  19. 19

    Synchronizing sync and local chrome.storage

  20. 20

    Chrome 61: Local Storage Location Changed?

  21. 21

    Where are cookies and local storage stored for Chrome?

  22. 22

    Google Chrome extenstion - local storage set and get

  23. 23

    how to remove the chrome.storage.local

  24. 24

    Store and retrieve data from local storage using chrome storage API

  25. 25

    chrome.webRequest redirectUrl with URL Saved in chrome.storage.local

  26. 26

    chrome extension: switching from localstorage to chrome.storage.local

  27. 27

    chrome.storage.local strange behaviour: confused by a duplicate object

  28. 28

    chrome local storage async pass data to callback properly

  29. 29

    uploading file from local storage to server with a chrome extension

HotTag

Archive