问题
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.
回答1:
Use chrome.storage.local.clear()
To check the status use a callback (optional):
chrome.storage.local.clear(function() {
var error = chrome.runtime.lastError;
if (error) {
console.error(error);
}
});
回答2:
You can also use chrome.storage.local.remove() method if you want to remove any specific or list of specific object from Storage
chrome.storage.local.remove(["Key1","key2"],function(){
var error = chrome.runtime.lastError;
if (error) {
console.error(error);
}
})
回答3:
Check this out
chrome.storage.local.remove(keyName,function() {
// Your code
// This is an asyn function
});
Check full details https://developer.chrome.com/extensions/storage
来源:https://stackoverflow.com/questions/31812937/how-to-clear-chrome-storage-local-cache-when-developing-a-chrome-extension