代码之家  ›  专栏  ›  技术社区  ›  spring

试图清除电子中的缓存,但似乎不起作用

  •  0
  • spring  · 技术社区  · 5 年前

    将要素添加到 Electron XMLHttpRequest

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


    function clearCache() {
      var win = remote.getCurrentWindow();
    
      win.webContents.session.clearStorageData(null, () => {
        // this NEVER gets called
         console.log('session cleared');
      });
    
      win.webContents.session.clearCache(function () {
        // this DOES get called
        console.log('cache cleared', (new Date()).getTime());
      });
    }
    

      // attempt to force new request
        var timestamp = (new Date()).getTime();
        obj.timestamp = timestamp;
    
        var url = domain + queryString.stringify(obj);
    
        xhttp.open("GET", url);
        xhttp.timeout = 1000 * 30; 
        xhttp.send();
    
    0 回复  |  直到 5 年前