How to clear the cache data in Electron(atom shell)?

后端 未结 8 864
有刺的猬
有刺的猬 2020-12-13 18:48

I want to clear cache data in Electron(atom-shell). I don\'t find any api like gui.App.clearCache()(node-webkit api to clear cache data) in Electron. If you find an

8条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-13 19:07

    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();
    

提交回复
热议问题