VOOZH about

URL: https://www.nuget.org/packages/Soenneker.Utils.HttpClientCache/

⇱ NuGet Gallery | Soenneker.Utils.HttpClientCache 4.0.1967




👁 Image
Soenneker.Utils.HttpClientCache 4.0.1967

Prefix Reserved
dotnet add package Soenneker.Utils.HttpClientCache --version 4.0.1967
 
 
NuGet\Install-Package Soenneker.Utils.HttpClientCache -Version 4.0.1967
 
 
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Soenneker.Utils.HttpClientCache" Version="4.0.1967" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Utils.HttpClientCache" Version="4.0.1967" />
 
Directory.Packages.props
<PackageReference Include="Soenneker.Utils.HttpClientCache" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Soenneker.Utils.HttpClientCache --version 4.0.1967
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Soenneker.Utils.HttpClientCache, 4.0.1967"
 
 
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Soenneker.Utils.HttpClientCache@4.0.1967
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Soenneker.Utils.HttpClientCache&version=4.0.1967
 
Install as a Cake Addin
#tool nuget:?package=Soenneker.Utils.HttpClientCache&version=4.0.1967
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

👁 alternate text is missing from this package README image
👁 alternate text is missing from this package README image
👁 alternate text is missing from this package README image
👁 alternate text is missing from this package README image

👁 alternate text is missing from this package README image
Soenneker.Utils.HttpClientCache

Providing thread-safe singleton HttpClients

Why?

'Long-lived' HttpClient static/singleton instances is the recommended use pattern in .NET. Avoid the unnecessary overhead of IHttpClientFactory, and definitely avoid creating a new HttpClient instance per request.

HttpClientCache provides a thread-safe singleton HttpClient instance per key via dependency injection. HttpClients are created lazily, and disposed on application shutdown (or manually if you want).

See Guidelines for using HttpClient

Installation

dotnet add package Soenneker.Utils.HttpClientCache

Usage

  1. Register IHttpClientCache within DI (Program.cs).
public static async Task Main(string[] args)
{
 ...
 builder.Services.AddHttpClientCache();
}
  1. Inject IHttpClientCache via constructor, and retrieve a fresh HttpClient.

Example:

public class TestClass
{
 IHttpClientCache _httpClientCache;

 public TestClass(IHttpClientCache httpClientCache)
 {
 _httpClientCache = httpClientCache;
 }

 public async ValueTask<string> GetGoogleSource()
 {
 HttpClient httpClient = await _httpClientCache.Get(nameof(TestClass));

 var response = await httpClient.GetAsync("https://www.google.com");
 response.EnsureSuccessStatusCode();

 var responseString = await response.Content.ReadAsStringAsync();
 return responseString;
 }
}
Product Versions Compatible and additional computed target framework versions.
.NET net10.0 net10.0 is compatible.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (117)

Showing the top 5 NuGet packages that depend on Soenneker.Utils.HttpClientCache:

Package Downloads
Soenneker.Cosmos.Client

A utility library for Azure Cosmos client accessibility

Soenneker.Blob.Container

A utility library for Azure Blob storage container operations

Soenneker.Validators.Email.Disposable.Online

A validation module checking for disposable email addresses via online sources

Soenneker.Queue.Client

A utility library for Azure Queue (Storage) client accessibility

Soenneker.Blob.Service

A utility library for Azure Blob storage service client operations

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.1967 1,516 6/17/2026
4.0.1965 1,801 6/16/2026
4.0.1964 2,059 6/16/2026
4.0.1963 18,741 6/10/2026
4.0.1962 96 6/10/2026
4.0.1961 7,190 6/10/2026
4.0.1960 5,476 6/9/2026
4.0.1959 16,329 6/9/2026
4.0.1958 18,986 6/6/2026
4.0.1957 3,969 6/6/2026
4.0.1956 668 6/6/2026
4.0.1955 97 6/6/2026
4.0.1954 3,524 6/6/2026
4.0.1953 2,897 6/6/2026
4.0.1952 1,063 6/6/2026
4.0.1950 2,216 6/5/2026
4.0.1949 9,060 6/5/2026
4.0.1947 62,863 5/13/2026
4.0.1946 1,682 5/13/2026
4.0.1945 8,866 5/12/2026
Loading failed

Update dependency Soenneker.Utils.Runtime to 4.0.1027 (#2257)