6

When using "Load unpacked extension". I have to pass a query string (eg ?v=\d+) to scripts included in the background page to break the cache.

Is there any way to disable this caching behavior?

12345
  • 565
  • 7
  • 12
  • Why do you use Load unpacked extension? Can't you just click on "Reload"? – Rob W Jul 27 '12 at 14:26
  • 2
    I use reload, but for some reason it still keeps the cache on the extension resources. – 12345 Jul 28 '12 at 17:01
  • That bug sounds familiar. I've experienced it in the past, but not having trouble any more (I've created an extension for quicker extension development, see [this post](http://stackoverflow.com/questions/2963260/how-do-i-auto-reload-a-chrome-extension-im-developing/9645435#9645435)). Which Chrome version are you using? – Rob W Jul 28 '12 at 20:34
  • 2
    I thought that I experienced the bug again. After some headaches, I discovered that I copied the wrong files. Make sure that you check that the relevant files are correctly SAVED to the relevant directory. – Rob W Jul 30 '12 at 23:12
  • The dev tools have an option to disable the cache, i don't know if this cache includes extensions' files, but you could try it. Nonetheless, like the previous comment says, be sure to edit and save the relevant files :D (I fell for this many times) – Cesar Varela Oct 19 '12 at 01:54
  • Pressing the "reload" button stopped to reload background.js for me. I want to be sure, my users won't experience the same issue. – Nakilon Dec 18 '12 at 18:22

1 Answers1

0

Maybe try keeping a file with an update number and when your users open the extension it detects the new update and clears the cache? You can add cache permission in the extension manifest like below:

"permissions": [
  "browsingData",
],

Then in your extension clear the cache like so:

var callback = function () {
  // Do something clever here once data has been removed.
};

var millisecondsPerWeek = 1000 * 60 * 60 * 24 * 7;
var oneWeekAgo = (new Date()).getTime() - millisecondsPerWeek;
chrome.browsingData.remove({
  "since": oneWeekAgo
}, {
  "appcache": true,
  "cache": true,
  "cookies": true,
  "downloads": true,
  "fileSystems": true,
  "formData": true,
  "history": true,
  "indexedDB": true,
  "localStorage": true,
  "pluginData": true,
  "passwords": true,
  "webSQL": true
}, callback);
Hunter Larco
  • 785
  • 5
  • 17