Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome.Storage.Local Persistence

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).

like image 521
Matt White Avatar asked Apr 22 '14 04:04

Matt White


People also ask

Where is Chrome local storage stored?

Google Chrome records Web storage data in a SQLite file in the user's profile. The subfolder containing this file is " \AppData\Local\Google\Chrome\User Data\Default\Local Storage " on Windows, and " ~/Library/Application Support/Google/Chrome/Default/Local Storage " on macOS.

Can I delete Chrome local storage?

Open the Google Chrome Console by pressing F12 key. Select “Application” in the console's top menu. Select “Local Storage” in the console's left menu. Right click your site(s) and click clear to delete the local storage.

Is Chrome local storage safe?

Local storage is inherently no more secure than using cookies. When that's understood, the object can be used to store data that's insignificant from a security standpoint.

What is persistent storage browser?

Persistent storage is any data storage device that retains data after power to that device is shut off.


1 Answers

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.

like image 145
kalman Avatar answered Oct 24 '22 17:10

kalman