I know that I can intercept the requests and exclude processing of certain types of resources: images, media, etc. As far as I understand, this only reduces work on my local machine.
var browser = await Puppeteer.LaunchAsync(options, null);
var page = await browser.NewPageAsync();
...
await page.SetRequestInterceptionAsync(true);
page.Request += (sender, e) => {
switch (e.Request.ResourceType) {
case ResourceType.Image:
case ResourceType.ImageSet:
case ResourceType.Media:
case ResourceType.Font:
e.Request.AbortAsync();
break;
default:
e.Request.ContinueAsync();
break;
}
};
Is there a way to somehow tell the server not to waste time preparing these resources so that the answer comes to me earlier?
Just for context, here's an example of how I navigate to a page and want to speed up the process:
var url = "https://...";
var timeout = 100000;
var response = await page.GoToAsync(url, timeout,
new WaitUntilNavigation[] { WaitUntilNavigation.Networkidle2 }
);
If you have control in server side,you can design a couple of RESTful APIs. Then you'll send json data and receive json data.
If you don't, you may try http Accept header. e.g
Accept: text/*Reference: