Give Flurl 4’s Cached Proxy Client a Stable Name
Use Flurl’s client cache to retain distinct proxy configurations without applying a random route choice repeatedly during request construction.
var client = clients.GetOrAdd(
"proxy-east",
"https://example.com",
builder => builder.ConfigureInnerHandler(handler =>
handler.Proxy = new WebProxy("http://203.0.113.10:8080")));
Here clients is Flurl 4's IFlurlClientCache. Select the route before lookup and give its reusable client a stable name. For permitted public requests, the HTTP proxy list offers candidates for the inner handler's WebProxy URL. Reusing proxy-east with a new proxy value is not a per-request reconfiguration of the client already retained there.
Use the handler API matching the application's chosen type; Flurl documents another configuration path for SocketsHttpHandler.
Keep the selected route in operation metadata and call through its corresponding client. A random choice every time a factory is consulted can otherwise give one logical job inconsistent policies.
Own the cache for an application scope and bound its growth. A changing temporary proxy list can accumulate clients and resources; use safe route identifiers for names/logs rather than embedded passwords.
This uses Flurl 4's named-cache interface instead of copying old custom factory infrastructure or changing a live handler during another request.