Reuse cache between launches in headless mode
See original GitHub issueSteps to reproduce
Tell us about your environment:
- Puppeteer version: 1.3.0
- Platform / OS version: Linux / CentOS 7.4.1708
- Node.js version: 8.11.1
What steps will reproduce the problem?
- Run the script (userDataDir is expected to be empty)
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({
userDataDir: '/tmp/user-data-dir',
headless: true,
args: ['--no-sandbox'],
});
const page = await browser.newPage();
const response = await page.goto('https://example.com/');
console.log(response.fromCache());
await browser.close();
})();
Console:
false
- Run the script for the second time
What is the expected result?
true
What happens instead?
false
Puppeteer works as expected in headfull mode, though.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:15
- Comments:9 (1 by maintainers)
Top Results From Across the Web
Caching in headless server-side rendering mode
Implement caching in the JavaScript layer. For example, you can: Add memory caching to the Node server to save JSON for a route...
Read more >Improving Puppeteer Performance - browserless docs
We've found that when using this option you can significantly speed up your existing sessions by having a full cache of all asset...
Read more >Automatically disable browser cache in chrome while running ...
I am trying to run tests using protractor but ...
Read more >Web Scraping with a Headless Browser: A Puppeteer Tutorial
We can force Puppeteer to use a custom path for storing data like cookies and cache, which will be reused every time we...
Read more >Getting Started with Headless Chrome - Chrome Developers
# Starting Headless (CLI). The easiest way to get started with headless mode is to open the Chrome binary from the command line....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The initial script works for me on v1.18.1. But it doesn’t work when request interception is on.
I have found out that page.setRequestInterception(true) method disables cache. Indeed; there is a test in puppeteer (page.spec.js) which says that page cache ‘should stay disabled when toggling request interception on/off’. @aslushnikov, can you please explain the idea behind that test? Is it safe to manually enable cache when request interception is on?
fwiw, still seeing this on puppeteer@1.7.0
Its not the end of the world, but there are use cases where reusing/sharing a cache across multiple browser instances makes sense, so it would be cool if this could be addressed.