Skip to content

Conversation

@amprew
Copy link
Contributor

@amprew amprew commented Dec 15, 2017

Fixes: #1556

Implements Page.disableCache(disabled) method.

@amprew amprew changed the title 1556 feat(Page): add disableCache() to Page object Dec 15, 2017
docs/api.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's name this page.setCacheEnabled to be aligned with page.setJavascriptEnabled method that we already have.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have made these changes 👍

@amprew amprew changed the title feat(Page): add disableCache() to Page object feat(Page): add setCacheEnabled() to Page object Dec 16, 2017
@amprew amprew changed the title feat(Page): add setCacheEnabled() to Page object feat(Page): add setCacheEnabled(enabled) to Page object Dec 16, 2017
Copy link
Contributor

@aslushnikov aslushnikov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andrewwwcollins The fromCache/fromServiceWorker methods are just landed: #1971. Are you interesteed in landing this PR? It would be nice have.

docs/api.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add:

By default, caching is enabled.

test/test.js Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please use one of the test/assets/cached/ assets intead of chromestatus.com website? We aim for the hermetic tests.

@amprew
Copy link
Contributor Author

amprew commented Feb 7, 2018

@aslushnikov - yes I can make these changes this evening.

I have made these changes now.

@amprew amprew force-pushed the 1556 branch 4 times, most recently from 3d67b13 to 550ea85 Compare February 7, 2018 17:45
test/test.js Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

two nits:

  1. Let's start from making sure it's cached, and then busting caching with this method
  2. Can we load-and-reload initially to make sure the stylesheet is cached?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have made these changes now. I needed to reset the responses array twice. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I sent a comment but for some reason it didn't get posted to github.
Let me re-type it here:

I needed to reset the responses array twice. What do you think?

You can avoid this by subscribing after the page.goto. You can also save a few lines by storing resources in the map:

const responses = new Map();
page.on('response', r => responses.set(r.url().split('/').pop(), r));

await page.goto(server.PREFIX + '/cached/one-style.html');
await page.reload();
expect(responses.get('one-style.css').fromCache()).toBe(true);

await page.setCacheEnabled(false);
await page.reload();
expect(responses.get('one-style.css').fromCache()).toBe(true);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah nice, didn't think of subscribing to the event later. Could be an issue when the responses map gets larger because of no filtering due to more resources being added. But I like this for the current solution.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a note for anyone else who goes to look at the above code the second expectation should be toBe(false).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have made those changes now.

@amprew amprew force-pushed the 1556 branch 3 times, most recently from 3247d00 to eff7da3 Compare February 7, 2018 23:03
@amprew
Copy link
Contributor Author

amprew commented Feb 7, 2018

@aslushnikov - is the appveyor continuous-integration required for this PR? I have had it passing before it just seems a bit flakey. I can rerun them if you think necessary.

Andrew Collins added 2 commits February 7, 2018 23:32
This change adds in the `Page.setCacheEnabled(enabled)` method to toggle ignoring cache for each request.
@aslushnikov
Copy link
Contributor

@aslushnikov - is the appveyor continuous-integration required for this PR? I have had it passing before it just seems a bit flakey. I can rerun them if you think necessary.

@andrewwwcollins appveyour is very flaky for us; this has nothing to do with your change.

Thank you for you time.

@aslushnikov aslushnikov merged commit ac1b9a0 into puppeteer:master Feb 8, 2018
drew-diamantoukos pushed a commit to drew-diamantoukos/puppeteer that referenced this pull request Feb 9, 2018
- Adding missing language tags to markdown code blocks.
- Switching `npm` to `yarn` in README to be consistent with what repo is using locally/with travis.

Removed unneeded  and  for yarn command per code review

Also removing  from travis and appveyor yarn invocations

Fixed merge conflicts and yarn references

Removed yarn.lock and added language to code fence

Cheeky capital letter

Touched up numbering (and also switched git email account due to CLA mis-match)

feat(Page): add `setCacheEnabled(enabled)` to Page object (puppeteer#1609)

This change adds in the `Page.setCacheEnabled(enabled)` method to toggle ignoring cache for each request.

Fixes puppeteer#1556.

docs(CONTRIBUTING): update contributing.md (puppeteer#1973)
@amprew amprew deleted the 1556 branch February 20, 2018 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants