Nativefier: Support clearing data (cookies, cache, localstorage, etc) on exit

Created on 1 Feb 2017  路  6Comments  路  Source: jiahaog/nativefier

Hello, tell me how to do to clear the cache in applications AppData\Roaming\-nativefier- folder on exit?
I found the function menu button, can you do something like that at the closing of the outlet or remove the application cache?
Thanks.

Specifications

  • Version of Nativefier (run $ nativefier --version): v7.0.1
  • Version of Node.js (run $ node --version): v7.4.0
  • OS: Windows
  • Architecture 32, 64
feature-request

Most helpful comment

if any one need this just

i add clear Storage Data order to close

just replace this in \resources\app\lib\main.js mainWindow.on('close', function(event)

with
mainWindow.on('close', function(event) { if (mainWindow.isFullScreen()) { if (nativeTabsSupported()) { mainWindow.moveTabToNewWindow(); } mainWindow.setFullScreen(false); mainWindow.once('leave-full-screen', maybeHideWindow.bind(_this, mainWindow, event, options.fastQuit)); } maybeHideWindow(mainWindow, event, options.fastQuit, options.tray); var session = mainWindow.webContents.session; session.clearStorageData(function() { session.clearCache(function() { }); }); });

and it's will working every time you close app (Ctrl+w)(alt+f4) or close menu button will clear c Storage Data, Cookies cache, etc.

i will try to add it to when app start too to be sure everything is cleared

All 6 comments

I found the cache cleaning feature on the menu button, tell me whether it is possible to insert it before exiting? I can not understand what the function of the output of the application is responsible.
Thank you.

const clearAppData = () => {
    dialog.showMessageBox(mainWindow, {
        type: 'warning',
        buttons: ['Yes', 'Cancel'],
        defaultId: 1,
        title: 'Clear cache confirmation',
        message: 'This will clear all data (cookies, local storage etc) from this app. Are you sure you wish to proceed?'
    }, response => {
        if (response === 0) {
            const session = mainWindow.webContents.session;
            session.clearStorageData(() => {
                session.clearCache(() => {
                    mainWindow.loadURL(options.targetUrl);
                });
            });
        }
    });
};

MainWindow.js#81

anyone get this work ???

+1

I would really appreciate to get this feature.

if any one need this just

i add clear Storage Data order to close

just replace this in \resources\app\lib\main.js mainWindow.on('close', function(event)

with
mainWindow.on('close', function(event) { if (mainWindow.isFullScreen()) { if (nativeTabsSupported()) { mainWindow.moveTabToNewWindow(); } mainWindow.setFullScreen(false); mainWindow.once('leave-full-screen', maybeHideWindow.bind(_this, mainWindow, event, options.fastQuit)); } maybeHideWindow(mainWindow, event, options.fastQuit, options.tray); var session = mainWindow.webContents.session; session.clearStorageData(function() { session.clearCache(function() { }); }); });

and it's will working every time you close app (Ctrl+w)(alt+f4) or close menu button will clear c Storage Data, Cookies cache, etc.

i will try to add it to when app start too to be sure everything is cleared

It would be a nice feature, if it would only delete cookies, which are for other origins than the --internal URLs.

If you're just looking to clear cache:
(not my code, just taken from Amrzxc)

var session = mainWindow.webContents.session; session.clearStorageData(function() { session.clearCache(function() { }); });

Was this page helpful?
0 / 5 - 0 ratings

Related issues

theman8631 picture theman8631  路  5Comments

mklaber picture mklaber  路  5Comments

raulcraveiro picture raulcraveiro  路  4Comments

jamiewilson picture jamiewilson  路  5Comments

jjgalvez picture jjgalvez  路  3Comments