0

To provide some custom caching via a webextension, I use web_accessible_resources and redirect accesses towards them in a background script – see my previous question for details.

While that works content wise, I cannot find a way to change the response headers of the cached content, for example the Last-Modified header. So when I cache content that the original website does some consistence checks on, this will fail.

I tried to intercept the redirected response with an onHeadersReceived handler, but this never triggers as “Only requests made using HTTP or HTTPS will trigger events” and my redirect uses the moz-extension:// protocol.

How does one set response headers when serving web_accessible_resources? Is it possible at all?

Rycec
  • 31
  • 3
  • Since Firefox is unable to intercept moz-extension:// scheme in webRequest even for extension's own URLs, I guess your only option is to register a service worker inside a content script (I don't know though how that would work on sites that already have one). – wOxxOm May 02 '20 at 05:12
  • @wOxxOm Nice idea, didn't even consider service workers yet. I have to try if 1) they can be created by a content script and 2) what their scope is in that case (hopefully that of the extension). Likely, a worker needs to be combined with the existing method of a webRequest that does the redirect first. The worker would then only add the headers. – Rycec May 04 '20 at 22:46

0 Answers0