0

I'm trying to wrap an existing web app in an Electron app in order to improve the performance.

I would like to override the cache strategy for certain web service calls as I know it will improve performance based on the way I use the website.

I don't control the web app so I cannot make any changes to that.

I have wrapped the web app in a BrowserView. Some of the endpoints that the web app using have have this response header: cache-control: no-cache, no-store, no-transform.

I would like to cache the result for 1 minute even though the server tell me not to.

So far I have tried to override the response header like this:

session.defaultSession.webRequest.onHeadersReceived((details, callback) => {
  let headers = details.responseHeaders

  headers["Cache-Control"] = ["max-age=60"]

  return callback({responseHeaders: headers})
})

But Electron is ignoring the updated response header entirely.

Any ideas to how I can force another caching strategy than the server suggests?

jonasmaturana
  • 287
  • 3
  • 10
  • This may not be possible, in chrome you can't do something like this and since electron is at the end of the day just a chromium implementation, I don't think it is possible either. See: https://stackoverflow.com/a/17382259/10213537 – Ameer Jul 18 '21 at 15:49
  • Thanks for the comment I guess I can compile and use my own Chromium with support for cache override - that seems like the last option I should try to explore though :) – jonasmaturana Jul 18 '21 at 16:09

0 Answers0