问题
I made a plugin that loads a handful of pages of my game website, but I'd like it to also disable the cache as it loads. I can only find cache disabling during reloading. I could load the page, then reload it every time, but that seems not ideal. Is there some way I could disable the cache for my generated tabs, either by the tabs themselves or even the domain.
回答1:
What wOxxOm said is correct, using the webRequest API I could modify the cache-control headers. I needed to make a background script with this:
chrome.webRequest.onBeforeSendHeaders.addListener(
function (details) {
var headers = details.requestHeaders || [];
headers.push({
"name": "Cache-Control",
"value": "no-cache"
});
return {requestHeaders: headers};
},
{
urls: [
"*://test.domain.tv/*",
"*://domain.tv/*"
]
},
[]
);
I also had to add "webRequest" to my manifest.
来源:https://stackoverflow.com/questions/45725712/disable-cache-chrome-extension