Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable http cache for electron app after packaging to .exe using electron-packager

I have an electron app, that loads some css's from spring boot server. When I run app from npm from sources, I can run as

ng build && electron . --disable-http-cache

and it works without the cache. If I build my app with electron-packager to app.exe, how can I disable cache. Start .exe-file with --disable-http-cache doesn't work

UPDATE The only approach that works is to clear cache from main process before app loads the page. But is there any another way to disable cache?

like image 288
Daniel Prosianikov Avatar asked Mar 05 '19 08:03

Daniel Prosianikov


1 Answers

Another possibility is to use Electron's commandLine.appendSwitch () in the main process on the app object, right before anything gets executed:

const { app } = require ("electron");

app.commandLine.appendSwitch ("disable-http-cache");
// any other main process code

This will append --disable-http-cache to Chromium's command line, just like appending it to the electron command would. When having this in code, you do no longer have to run your app with appending this switch as it will automatically be added.

like image 187
Alexander Leithner Avatar answered Sep 20 '22 23:09

Alexander Leithner