Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clear chrome.storage.local and chrome.storage.sync?

I've written a Chrome Extension for my library. It uses chrome.storage.local to cache things.

Does anyone know how to drop the cache for testing purposes? I can't really test things anymore as all the data is now in cache. I'd like to drop it and make sure it gets repopulated correctly, etc. How do I do that?

I tried "Refresh"-ing the extension but that did nothing. Removing and adding the extension doesn't appear to clean cache either.

like image 420
bodacydo Avatar asked Aug 04 '15 15:08

bodacydo


People also ask

Does Chrome sync local storage?

sync , the stored data will automatically be synced to any Chrome browser that the user is logged into, provided the user has sync enabled. When Chrome is offline, Chrome stores the data locally. The next time the browser is online, Chrome syncs the data. Even if a user disables syncing, storage.

How do I sync my Chrome storage?

With the extension's background page open, just go to the developer tools by pressing F12, then go to the Application tab. In the Storage section expand Local Storage. After that, you'll see all your browser's local storage there.

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.


1 Answers

Use chrome.storage.local.clear() and chrome.storage.sync.clear()

The API is asynchronous so to do subsequent actions to the storage, use a callback:

chrome.storage.local.clear(function() {     var error = chrome.runtime.lastError;     if (error) {         console.error(error);     }     // do something more }); chrome.storage.sync.clear(); // callback is optional 
like image 145
wOxxOm Avatar answered Sep 20 '22 11:09

wOxxOm