How to clear the cache data in Electron(atom shell)?
Solution 1:
The Electron stores it's cache in these folders:
Windows:C:\Users\<user>\AppData\Roaming\<yourAppName>\Cache
Linux:/home/<user>/.config/<yourAppName>/Cache
OS X:/Users/<user>/Library/Application Support/<yourAppName>/Cache
So deleting these folders can also help you. Of course this is one time solution ;-)
Solution 2:
You can use session.clearCache api.
var remote = require('remote');
var win = remote.getCurrentWindow();
win.webContents.session.clearCache(function(){
//some callback.
});
Solution 3:
If you want to clear any remnants of previous login sessions, you'd better use this:
loginWindow.webContents.session.clearStorageData()
Solution 4:
We are using this in our app...
const { app, session } = require('electron');
// ...
session.defaultSession.clearStorageData(null, (error: any) => {
// in our case we need to restart the application
// app.relaunch();
// app.exit();
});
Update for Electron 7:
await session.defaultSession.clearStorageData();
Solution 5:
Answer:
var remote = require('remote');
var win = remote.getCurrentWindow();
win.WebContents.session.cookies.get(details, callback) // getting cookies
win.WebContents.session.cookies.remove(details, callback) //deleting cookies
For more info: http://electron.atom.io/docs/v0.29.0/api/browser-window/