HTTPClients are reusable

Hi 👋, I wanted to write this article to tell you that instantiating a HttpClient class is often a costly operation. If you have a method that does something like: 1 2 3 4 5 6 public class Main { static void myMethod() { HttpClient client = new HttpClient() // do stuff } } You should refactor it ASAP. Either move the HttpClient into the class and perhaps ensure that the class is a Singleton or retrieve the HttpClient instance using an Object Pool pattern like the HttpClient class from System.Net.Http. ...

June 23, 2022 · 1 min · Denis Nuțiu