javascript - 带有/dev/null 的 Puppeteer Chrome cache_dir 正在创建文件夹/dev/null

标签 javascript node.js google-chrome command-line puppeteer

我正在使用以下参数运行 chrome-

const browser = await puppeteer.launch({
    headless: true,
    userDataDir: './user_data_dir/',
    args: [
        '--aggressive-cache-discard',
        '--disable-cache',
        '--disable-application-cache',
        '--disable-offline-load-stale-cache',
        '--disable-gpu-shader-disk-cache',
        '--disk-cache-dir=/dev/null',  // this is causing problem
        '--media-cache-dir=/dev/null', // this is causing problem
        '--disk-cache-size=1',
        '--media-cache-size=1',
        '--no-sandbox',
        '--disable-setuid-sandbox',
        '--disable-dev-shm-usage',
        '--disable-accelerated-2d-canvas',
        '--no-first-run',
        '--no-zygote',
        '--single-process',
        '--disable-gpu'
    ]
    });

但是,这是将文件夹创建为/dev/null ,其中包含缓存文件。我必须删除文件夹并重新创建空文件。

信息-
Ubuntu 14.04.6 LTS
nodejs -v: v10.14.0
npm -v: 6.4.1
npm version:
{ 'actor-google-serp': '1.0.0',
  npm: '6.4.1',
  ares: '1.14.0',
  cldr: '33.1',
  http_parser: '2.8.0',
  icu: '62.1',
  modules: '64',
  napi: '3',
  nghttp2: '1.34.0',
  node: '10.14.0',
  openssl: '1.1.0j',
  tz: '2018e',
  unicode: '11.0',
  uv: '1.23.2',
  v8: '6.8.275.32-node.36',
  zlib: '1.2.11' }

google-chrome --product-version: 80.0.3987.149

谁能指出我在哪里寻找诊断它的正确方向。谢谢

最佳答案

根据底部 here 的评论,似乎 --disk-cache-dir 正在做它应该在 headless 模式下做的事情。

尝试将其设置为

--media-cache-size=0
--disk-cache-size=0

或者,似乎可以使用 setCacheEnabled 忽略每个请求的缓存; See example

关于javascript - 带有/dev/null 的 Puppeteer Chrome cache_dir 正在创建文件夹/dev/null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60786130/

相关文章:

javascript - 淡出功能移动问题

javascript - NodeJS 中请求的资源不存在 'Access-Control-Allow-Origin' header

node.js - 如何在 Node.js repl 中禁用 .save 命令?

node.js - npm start Microsoft JScript 运行时错误 800A138F 需要对象

javascript - AngularJS 点击指令的 Google Chrome 内容保护政策

javascript - 打开后一秒显示 Angular UI 模态

javascript - dojo 获取 foreach 中当前节点的父节点

javascript - JavaScript 内部问题

javascript - 使用第三方库

javascript - 文件输入不会更新(Chrome 除外)