'How to clear cache for a Chrome extension's background process?
I see several questions about clearing cache in Chrome in general, but this is specific to my extension which uses a background script. I have an extension which retrieves Json data from a background script:
//In the content script
chrome.runtime.sendMessage({ query: 'getList' }, function (result) {
//Uses list data
});
Inside the background js file, I'm retrieve data from a JQuery ajax call:
//In a background script
chrome.runtime.onMessage.addListener(
function (request, sender, sendResponse) {
$.get('http://example.com/data.txt', function (result) {
sendResponse(result);
});
});
I have updated the context of the data.txt file on my server. However, the Chrome extension continues to use the old data. I have the same exact code running in a Firefox add-on, and in Firefox I see the new data immediately when updating the .txt file.
I don't know how to tell whether the actual issue is that the sendMessage() call is just using a cached value instead of going to my background script, or whether my background script is just returning a cached value instead of retrieving the update from my server.
I updated the .txt file over a day ago, so it's not just a short-term caching issue. What can I do to force the Chrome extension itself to refresh the data coming from the background script? It does not appear to be a local issue; even uninstalling and re-installing the script doesn't fix the issue; it's not that it's being cached in my local Chrome cache.
If I visit http://example.com/data.txt in Chrome (or any browser), I see the updated file.
I'm guessing that if I deployed a new package to the Chrome Developer Dashboard, then it would clear. But the whole reason I have this background script and JQuery call is so that I can easily update this data without having to re-deploy the extension whenever it changes.
Is there anything that can be done from the Chrome Developer Dashboard to force it to refresh?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
