node.js - Node Webkit 清除缓存

标签 node.js node-webkit

我最近发现 c:/Users/username/AppData/Local/AppName/Cache 包含超过 100K 的缓存文件。

我仔细阅读了一下,发现 gui.App.clearCache() 方法应该可以解决这个问题。 我在应用程序启动和关闭时执行此方法。 (在将 gui 分配给 require("nw.gui") 之后)

然而,这似乎并没有帮助。没有任何内容被删除。

知道这是为什么吗?

最佳答案

require 缓存显然只在 global.require.cache 上可用。

手动清除缓存使它对我有用。

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

gui.APP.clearCache()gui.Window.get().reloadIgnoringCache() 对我都没有任何影响。

关于node.js - Node Webkit 清除缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25143532/

相关文章:

javascript - Node.js - 使用多个查询异步构建 JSON

sql-server - 在sails js中检索多个结果集

javascript - Angular JS 自动更新事件 View

javascript - 离开主 html 后,window.close() 在 node-webkit 中停止工作

javascript - 如何在 node.js 中使用 promise

node.js - Cloud 9 ide 中的跨源 Node js

javascript - 无法禁用 X-Powered-By : Express

javascript - 在 nwjs (node-webkit) 中将数据从 nodejs 传递到 angular 的正确方法

python - 使用 python 实现基于 Web 的桌面应用程序

javascript - 如何在 Javascript/Node 中从 blob 写入 .wav 文件