Puneet Saini
Puneet Saini

Reputation: 597

Puppeteer Chrome cache_dir with /dev/null is creating a folder /dev/null instead

I am running chrome with following arguments-

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'
    ]
    });

However, this is creating the folder as /dev/null with cache files inside. I have to delete the folder and recreate the null file.

Information-

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

Can anyone please point me in the right direction where to look for to diagnose it. Thanks

Upvotes: 4

Views: 6140

Answers (1)

Max Gram
Max Gram

Reputation: 695

It seems like --disk-cache-dir is doing what it's supposed to do in headless mode according to comment at the bottom here.

Try setting it to

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

Alternatively, it seems to be possible to ignore cache for each request with setCacheEnabled; See example

Upvotes: 2

Related Questions