Skip to content
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

Browser caching doesn't seem to work #487

Closed
aslushnikov opened this issue Aug 23, 2017 · 10 comments · Fixed by #731
Closed

Browser caching doesn't seem to work #487

aslushnikov opened this issue Aug 23, 2017 · 10 comments · Fixed by #731
Labels

Comments

@aslushnikov
Copy link
Contributor

The following example reloads the example.com a few times.
For some reason, all the responses have status 200. If there was a caching, the responses would have status 304.

const puppeteer = require('.');

(async () => {
  const browser = await puppeteer.launch({headless: false});
  const page = await browser.newPage();
  await page.goto('https://example.com/');

  page.on('response', r => console.log(r.status + ' ' + r.url));
  await page.reload();
  await page.reload();
  await page.reload();
  browser.close();
})();

This was initially reported in #446.

@pavelfeldman
Copy link
Contributor

Ouch, you are likely getting into the wrong branch of this. The way it works is that browser receives 304, but instead of passing it into Blink, it is fetching data from disk cache and feeds Blink with the 200 response. Clueless renderer behaves as it is getting an OK response.

Not getting into that branch means that we don't have raw headers, don't report precise network timing, etc. I.e. needs to be fixed on the headless side. If you see this on Linux/Window headless and don't see it on a Mac, we are not plumbing the raw headers information the right way. Should be a straightforward fix in headless.

@aslushnikov
Copy link
Contributor Author

@pavelfeldman doesn't seem to be related to headless: it reproduces for me on mac headful and on mac headless.

@aslushnikov
Copy link
Contributor Author

Pavel bisected it down to chromium change.
Upstream bug: https://bugs.chromium.org/p/chromium/issues/detail?id=758090

@aslushnikov
Copy link
Contributor Author

For the record: this was fixed upstream in r498894.

aslushnikov added a commit to aslushnikov/puppeteer that referenced this issue Sep 9, 2017
The new chromium:
- supports executionContextId in Runtime.callFunctionOn protocol method
- supports passing objects as arguments in Runtime.callFuntionOn
  protocol method

This roll also fixes puppeteer#487.
aslushnikov added a commit that referenced this issue Sep 9, 2017
The new chromium:
- supports executionContextId in Runtime.callFunctionOn protocol method
- supports passing objects as arguments in Runtime.callFuntionOn
  protocol method

This roll also fixes #487.
@pokka
Copy link

pokka commented Dec 27, 2017

Still not getting the cache, all resources(png, css) got 200, but I'm using headless mode.
Can anyone help?

Tested in v1.0.0-rc:

const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch({ headless: true });
  const page = await browser.newPage({ context: 'default' });
  await page.goto('https://github.com/GoogleChrome/puppeteer/issues/487');

  page.on('response', r => console.info(r.status() + ' ' + r.url()));
  await page.reload();
  await page.reload();
  await page.reload();
  browser.close();
})();

@aslushnikov
Copy link
Contributor Author

@pokka the same happens to me if I just open the website in chrome and try to reload: all resources are loaded with 200 (check out devtools network panel). Looks like server disabled caching.

@robba86
Copy link

robba86 commented Feb 27, 2019

Any update on this? :)

@aslushnikov
Copy link
Contributor Author

@robba86 this has been fixed; if it doesn't work for you - please file another issue.

@ColCh
Copy link

ColCh commented Mar 22, 2019

@pokka it's working for me

set DEBUG env variable to 'puppeteer:*' and log things

then search for fromDiskCache. There is many requests with cache

@liuchuangjun321
Copy link

liuchuangjun321 commented Apr 10, 2019

@pokka it's working for me

set DEBUG env variable to 'puppeteer:*' and log things

then search for fromDiskCache. There is many requests with cache

@ColCh Can explain the details, thank you。
I am still not getting the cache, all resources(png, css) got 200,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants