New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reuse cache between launches in headless mode #2497
Comments
@blackdeman If that case is critical for you, you can simply clear cache and cookies before opening the same page in a new browser instance. |
We are experiencing the same issue with |
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. |
so is this still not possible in headless? |
This seems to be working on v1.14.0 based on my own tests. It wasn't working on 1.9.0 |
Indeed; works for me on v1.14.0. |
I managed to reproduce the issue with v1.16.0 using the following code: const puppeteer = require('puppeteer');
async function test() {
const browser = await puppeteer.launch({headless: true, args: ['--no-sandbox']});
const page = await browser.newPage();
const response = await page.goto('https://example.org');
console.log(response.fromCache());
await browser.close();
}
test();
Edit: Same on v1.14.0. |
The initial script works for me on v1.18.1. But it doesn't work when request interception is on. 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();
// enable request interception
await page.setRequestInterception(true);
page.on('request', request => {
request.continue();
});
const response = await page.goto('https://example.com/');
console.log(response.fromCache());
await browser.close();
})(); 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? await page._client.send('Network.setCacheDisabled', {
cacheDisabled: false
}); |
Similar questions are being asked in #4620 |
Steps to reproduce
Tell us about your environment:
What steps will reproduce the problem?
Console:
What is the expected result?
What happens instead?
Puppeteer works as expected in headfull mode, though.
The text was updated successfully, but these errors were encountered: