-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
perf: request block stylesheets and images on redirect pass #2168
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,8 @@ module.exports = { | |
{ | ||
"passName": "redirectPass", | ||
"useThrottling": false, | ||
// Speed up the redirect pass by blocking stylesheets, fonts, and images | ||
"blockedUrlPatterns": ["*.css", "*.jpg", "*.jpeg", "*.png", "*.gif", "*.svg", "*.ttf", "*.woff", "*.woff2"], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure about this one, but does it make sense to have these apply across There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah few random thoughts here
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
that's actually why I brought it up, so it wouldn't surprise us when someone does write a gatherer that tries it :)
but that's definitely something we rely on when we need to get around authentication or whatever. As an easy workaround to some of those issues, fetching in the context of the page can't be beat.
yeah, good point, and this is what really separates it from My real hesitation is magic while having no data about actual downsides. This is why we need users making custom gatherers :) In the meantime, I suspect we'll have to revisit scheduling of all of this for #1826 anyways, so I'm good with this. |
||
"gatherers": [ | ||
"http-redirect", | ||
"html-without-javascript" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,12 +40,12 @@ let GathererResults; // eslint-disable-line no-unused-vars | |
* iv. evaluateScriptOnLoad rescue native Promise from potential polyfill | ||
* v. cleanAndDisableBrowserCaches | ||
* vi. clearDataForOrigin | ||
* vii. blockUrlPatterns | ||
* | ||
* 2. For each pass in the config: | ||
* A. GatherRunner.beforePass() | ||
* i. navigate to about:blank | ||
* ii. all gatherers' beforePass() | ||
* ii. Enable network request blocking for specified patterns | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
and you can remove "vii. blockUrlPatterns" from above. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
* iii. all gatherers' beforePass() | ||
* B. GatherRunner.pass() | ||
* i. beginTrace (if requested) & beginDevtoolsLog | ||
* ii. GatherRunner.loadPage() | ||
|
@@ -112,7 +112,6 @@ class GatherRunner { | |
.then(_ => driver.dismissJavaScriptDialogs()) | ||
.then(_ => resetStorage && driver.cleanAndDisableBrowserCaches()) | ||
.then(_ => resetStorage && driver.clearDataForOrigin(options.url)) | ||
.then(_ => driver.blockUrlPatterns(options.flags.blockedUrlPatterns || [])) | ||
.then(_ => gathererResults.UserAgent = [driver.getUserAgent()]); | ||
} | ||
|
||
|
@@ -171,9 +170,15 @@ class GatherRunner { | |
* @return {!Promise} | ||
*/ | ||
static beforePass(options, gathererResults) { | ||
const blockedUrls = (options.config.blockedUrlPatterns || []) | ||
.concat(options.flags.blockedUrlPatterns || []); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how do unions of url patterns work? Last one wins? (just curious) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. aside: we really need to get the overloaded naming of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
oh, is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ! isnt supported, correct. |
||
const blankPage = options.config.blankPage; | ||
const blankDuration = options.config.blankDuration; | ||
const pass = GatherRunner.loadBlank(options.driver, blankPage, blankDuration); | ||
const pass = GatherRunner.loadBlank(options.driver, blankPage, blankDuration) | ||
// Set request blocking before any network activity | ||
// No "clearing" is done at the end of the pass since blockUrlPatterns([]) will unset all if | ||
// neccessary at the beginning of the next pass. | ||
.then(() => options.driver.blockUrlPatterns(blockedUrls)); | ||
|
||
return options.config.gatherers.reduce((chain, gatherer) => { | ||
return chain.then(_ => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
love having this in the default config as an example for custom configs