I have an WebAPI project with several endpoints. One (of several) endpoint calls an external endpoint via a static HttpClient, caches the result and answers following requests for a specified amount from the cache.
We sometimes have the situation were the cache is invalidated, 200 requests / second arrive at the endpoint and the external endpoint is very slow or unresponsive. The first request to the external endpoint sees that the cache is empty and queries the external endpoint. All subsequent requests also start an external HTTP GET call via the HttpClient since the first request did not write the result into the IMemoryCache. Basically, we further create load on the external endpoint if it's unresponsive.
I'm trying to find a way that our WebAPI Method only fires one external HTTP GET call and all other requests wait for the same answer. I've read answers like How to Throttle all outgoing asynchronous calls to HttpClient across multiple threads in .net Core API project to throttle requests but I want a different kind of throttling for one endpoint with one global HttpClient instance