C#C
C#3y ago
Head0nF1re

❔ HttpClient vs IHttpClientFactory

Hey. I have a few doubts regarding HttpClient, I was reading:

And I was wondering why the IHttpClientFactory should only be used for short-lived connections (and what can be considered short-lived, like a few requests between a request flow?) ?

Also, in the context of a pulling service I assume that what I need is HttpClient without IHttpClientFactory (and configure PooledConnectionLifetime to prevent DNS problems) since it's requesting the same endpoint frequently, right?

I'm thinking in having a singleton SomeServiceHttpClient for each endpoint being used in the pulling service. Is there a difference in having it static or as singleton, I kept seeing posts about people having DNS issues with it being singleton?

Thanks
Was this page helpful?