iSponsorBlockTV icon indicating copy to clipboard operation
iSponsorBlockTV copied to clipboard

Reduce dns requests with cache

Open adriadam10 opened this issue 2 years ago • 4 comments

Is your feature request related to a problem? Please describe. The script is requesting the ip of www.youtube.com every 10 seconds, which is quite a lot. image image

Describe the solution you'd like It would be great some kind of dns caching to stop this "bombing".

adriadam10 avatar Nov 08 '23 16:11 adriadam10

it's interesting that in the main function the ttl is set to 300 in the tcp_connector variable. But in reality is using the default ttl of aiohttp according to their docs image

adriadam10 avatar Nov 09 '23 21:11 adriadam10

It’s like that since pyytlounge doesn’t use an already defined web session and creates a new one for each request. That library could be easily modified to use a web session and fix this problem. @FabioGNR would I be able to make such pr to you lib, maintaining the default functionality of not giving an already defined session?

dmunozv04 avatar Nov 09 '23 21:11 dmunozv04

Yeah, it should just use one session:

Unless you are connecting to a large, unknown number of different servers over the lifetime of your application, it is suggested you use a single session for the lifetime of your application to benefit from connection pooling.

If you need that to be a configurable session that's of course no problem. Feel free to submit a PR!

FabioGNR avatar Nov 11 '23 11:11 FabioGNR

If you need that to be a configurable session that's of course no problem. Feel free to submit a PR!

Great, I’ll make a PR soon-ish!

dmunozv04 avatar Nov 11 '23 11:11 dmunozv04