Try to search your question here, if you can't find : Ask Any Question Now ?

Using puppeteer for cachewarmer

HomeCategory: stackoverflowUsing puppeteer for cachewarmer
Avatarbhawya asked 5 months ago

I have a long txt file with ~1000 urls, which needs to be executed, to warm the varnish cache. Since i need puppeteer, is that there is important content loaded by AJAX call.

This is my first attempt, but not master in node. The real issue is that it make a 100% load, and starts too many threads.

const puppeteer = require('puppeteer');
const readline = require('readline');
const fs = require('fs');

const rl = readline.createInterface({
    input: fs.createReadStream('varnish-warmer.txt')
  });

rl.on('line', (line) => {
(async () => {
    if (line != '') {
    const browser = await puppeteer.launch();
        const page = await browser.newPage();
        await page.goto(line);
        await page.waitFor(1000);

        browser.close();
    }

})();
});
1 Answers
Best Answer
AvatarFernando answered 5 months ago
Your Answer

20 + 13 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com