I have an app running on both Web (Chrome mainly) and Electron which loads enormous static files. And the static files will all response with HTTP headers like below so they can be cached by the chromium.
Cache-Control: max-age=31536000
Expires: 31536000
So I wonder, what's the max cache size which cached by this way in default?
And, is there any ways to change the max cache size in Electron via js?
I read the docs of Electron but it doesn't mention it.
Thanks a lot for anyone help!
This answer on SuperUser states that Chrome's default maximum total cache size depends on how much disk space you have left on your device.
However, as shown in this answer, you can set another cache size yourself using the command-line switch
--disk-cache-size=xxx
where xxx
is in bytes. This can be done programmatically for Electron using the app
module. In your main process' source, add the following to increase or decrease the cache size:
const { app } = require ("electron");
app.commandLine.appendSwitch ("disk-cache-size", "xxx");
Please note that this does not clear the cache if it already is too big (you'd have to do that yourself) and that Chromium uses a complex method to decide whether to actually use this value, see the answers on SuperUser linked above.