6

使用“加载解压扩展”时。我必须将查询字符串(例如?v=\d+)传递给后台页面中包含的脚本来破坏缓存。

有没有办法禁用这种缓存行为?

4

1 回答 1

0

也许尝试保留一个带有更新号的文件,当您的用户打开扩展程序时,它会检测到新的更新并清除缓存?您可以在扩展清单中添加缓存权限,如下所示:

"permissions": [
  "browsingData",
],

然后在您的扩展中清除缓存,如下所示:

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);
于 2012-12-24T15:08:50.410 回答