Search code examples
node.jsnode-webkit

Node Webkit clear cache


I recently discovered that c:/Users/username/AppData/Local/AppName/Cache contained over 100K cache files.

I read up a bit and saw that the gui.App.clearCache() method should fix this. I execute this method at start and at shutdown of the app. (after assigning gui to require("nw.gui"))

However, this doesn't seem to help. Nothing is being deleted.

Any ideas why that is?


Solution

  • The require cache is apparently only available on global.require.cache.

    Clearing that cache manually made it work for me.

    for(module in global.require.cache){
        if(global.require.cache.hasOwnProperty(module)){
            delete global.require.cache[module];
        }
    }
    location.reload()
    

    Neither the gui.APP.clearCache() nor the gui.Window.get().reloadIgnoringCache() had any effect for me.