How does Network.setBlockedURLs scale

455 views
Skip to first unread message

Soufiane Ghzal

unread,
Apr 3, 2020, 5:24:25 AM4/3/20
to chrome-debugging-protocol
Hi,
CDP has a method Network.setBlockedURLs that gives us the opportunity to block various urls (https://chromedevtools.github.io/devtools-protocol/tot/Network/#method-setBlockedURLs)
I don't really know how the implementation works behind the scene, so I don't know how it scales with large number of URLs blocked.

Anyone has a rough idea of whether or not it would impact requests performances if I used it to block 10/100/1000/more... urls?

Thanks

Andrey Kosyakov

unread,
Apr 3, 2020, 3:59:11 PM4/3/20
to Soufiane Ghzal, chrome-debugging-protocol
Hi Souflane,

it is not specifically designed to scale, it's just a set of glob patterns and the entire set is linearly iterated when a network resource fetch is attempted. Given the overall overhead associated with network requests, having a few hundred or patterns probably won't be noticeable, but something on the order of some tens of thousands may potentially slow things down. Another thing to consider is that this list is maintained in the renderer and there's additional overhead to replicate it to new renderers during cross-process navigation.

Depending on the size of the list, network interception may be your other option -- please see the Fetch domain. You will basically receive an event when the network request is about to be sent, along with the resource URL, and will be able to implement the URL matching logic on the client side, in a way that optimally suits your application. There will be certain overhead as well, but of a different kind -- sending the protocol messages back and forth between the browser and the client and some additional proxying done by the underlying implementation of the Fetch domain.

Whichever is more efficient is highly dependent on the size of the list and other usage nuances.

Best regards,
Andrey.




--
You received this message because you are subscribed to the Google Groups "chrome-debugging-protocol" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chrome-debugging-p...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/chrome-debugging-protocol/c066f41b-85c0-4b8c-b8c3-880ab880080e%40googlegroups.com.

Soufiane Ghzal

unread,
Apr 5, 2020, 2:50:58 AM4/5/20
to chrome-debugging-protocol
Hi Andrey,

Thank you for your response, that makes perfect sense and helps to better understand how it works!
Reply all
Reply to author
Forward
0 new messages