Soenneker.Utils.HttpClientCache 2.1.377

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Soenneker.Utils.HttpClientCache --version 2.1.377
NuGet\Install-Package Soenneker.Utils.HttpClientCache -Version 2.1.377
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="2.1.377" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Soenneker.Utils.HttpClientCache --version 2.1.377
#r "nuget: Soenneker.Utils.HttpClientCache, 2.1.377"
#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.
// Install Soenneker.Utils.HttpClientCache as a Cake Addin
#addin nuget:?package=Soenneker.Utils.HttpClientCache&version=2.1.377

// Install Soenneker.Utils.HttpClientCache as a Cake Tool
#tool nuget:?package=Soenneker.Utils.HttpClientCache&version=2.1.377

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 Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (12)

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

Package Downloads
Soenneker.Blob.Container The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

A utility library for Azure Blob storage container operations

Soenneker.Validators.Email.Disposable.Online The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

A validation module checking for disposable email addresses via online sources

Soenneker.YouTube.Client The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

An async thread-safe singleton for the YouTube client YouTubeExplode

Soenneker.Queue.Client The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

A utility library for Azure Queue (Storage) client accessibility

Soenneker.Queue.Service The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

A utility library for Azure Queue (Storage) service client (QueueServiceClient) accessibility

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.1.405 34 5/3/2024
2.1.404 352 4/30/2024
2.1.403 119 4/30/2024
2.1.402 263 4/30/2024
2.1.401 317 4/30/2024
2.1.400 484 4/30/2024
2.1.399 455 4/30/2024
2.1.398 322 4/29/2024
2.1.397 254 4/29/2024
2.1.396 72 4/29/2024
2.1.395 1,062 4/29/2024
2.1.394 358 4/29/2024
2.1.393 770 4/29/2024
2.1.392 197 4/28/2024
2.1.391 70 4/28/2024
2.1.390 608 4/28/2024
2.1.389 91 4/28/2024
2.1.388 684 4/28/2024
2.1.387 435 4/28/2024
2.1.386 69 4/28/2024
2.1.385 646 4/28/2024
2.1.384 65 4/28/2024
2.1.383 485 4/28/2024
2.1.382 71 4/28/2024
2.1.381 1,150 4/28/2024
2.1.380 600 4/27/2024
2.1.379 80 4/27/2024
2.1.378 76 4/27/2024
2.1.377 1,558 4/20/2024
2.1.376 570 4/20/2024
2.1.375 509 4/19/2024
2.1.374 250 4/19/2024
2.1.373 69 4/19/2024
2.1.372 982 4/19/2024
2.1.371 505 4/19/2024
2.1.370 475 4/19/2024
2.1.369 355 4/19/2024
2.1.368 120 4/18/2024
2.1.367 67 4/18/2024
2.1.366 1,116 4/15/2024
2.1.365 421 4/14/2024
2.1.364 495 4/13/2024
2.1.363 549 4/12/2024
2.1.362 69 4/12/2024
2.1.361 447 4/12/2024
2.1.360 257 4/12/2024
2.1.359 415 4/12/2024
2.1.358 71 4/12/2024
2.1.357 686 4/12/2024
2.1.356 91 4/12/2024
2.1.355 724 4/12/2024
2.1.354 71 4/12/2024
2.1.353 299 4/11/2024
2.1.352 448 4/11/2024
2.1.351 75 4/11/2024
2.1.350 600 4/10/2024
2.1.349 70 4/10/2024
2.1.348 592 4/9/2024
2.1.347 74 4/9/2024
2.1.346 1,271 4/2/2024
2.1.345 222 4/2/2024
2.1.344 282 4/1/2024
2.1.343 103 4/1/2024
2.1.342 803 3/29/2024
2.1.341 80 3/29/2024
2.1.340 666 3/25/2024
2.1.339 67 3/25/2024
2.1.338 549 3/25/2024
2.1.337 809 3/20/2024
2.1.336 87 3/20/2024
2.1.335 890 3/19/2024
2.1.334 85 3/19/2024
2.1.333 326 3/19/2024
2.1.332 331 3/19/2024
2.1.331 539 3/18/2024
2.1.330 79 3/18/2024
2.1.329 554 3/18/2024
2.1.328 589 3/16/2024
2.1.327 328 3/15/2024
2.1.326 699 3/13/2024
2.1.325 407 3/13/2024
2.1.324 124 3/13/2024
2.1.323 99 3/13/2024
2.1.322 525 3/13/2024
2.1.321 87 3/13/2024
2.1.320 304 3/13/2024
2.1.319 71 3/13/2024
2.1.318 68 3/13/2024
2.1.317 325 3/12/2024
2.1.316 82 3/12/2024
2.1.315 374 3/12/2024
2.1.314 451 3/12/2024
2.1.313 484 3/12/2024
2.1.312 320 3/11/2024
2.1.311 667 3/11/2024
2.1.310 264 3/11/2024
2.1.309 526 3/10/2024
2.1.308 80 3/10/2024
2.1.307 670 3/8/2024
2.1.306 182 3/8/2024
2.1.305 424 3/8/2024
2.1.304 57 3/8/2024
2.1.303 447 3/8/2024
2.1.302 64 3/8/2024
2.1.301 798 3/6/2024
2.1.300 87 3/6/2024
2.1.299 725 3/4/2024
2.1.298 403 3/4/2024
2.1.297 333 3/4/2024
2.1.296 93 3/4/2024
2.1.295 878 3/3/2024
2.1.294 166 3/2/2024
2.1.293 437 3/2/2024
2.1.292 84 3/2/2024
2.1.291 1,500 2/29/2024
2.1.290 302 2/29/2024
2.1.289 74 2/29/2024
2.1.288 168 2/29/2024
2.1.287 70 2/29/2024
2.1.286 507 2/29/2024
2.1.285 981 2/26/2024
2.1.284 77 2/26/2024
2.1.283 417 2/25/2024
2.1.282 147 2/25/2024
2.1.281 655 2/23/2024
2.1.280 373 2/23/2024
2.1.279 377 2/22/2024
2.1.278 184 2/22/2024
2.1.277 271 2/22/2024
2.1.276 85 2/22/2024
2.1.275 176 2/21/2024
2.1.274 88 2/21/2024
2.1.273 436 2/21/2024
2.1.272 96 2/21/2024
2.1.271 77 2/21/2024
2.1.270 467 2/21/2024
2.1.269 231 2/21/2024
2.1.268 85 2/21/2024
2.1.267 203 2/21/2024
2.1.266 75 2/21/2024
2.1.265 223 2/21/2024
2.1.264 79 2/21/2024
2.1.263 338 2/21/2024
2.1.262 421 2/20/2024
2.1.261 275 2/20/2024
2.1.260 111 2/20/2024
2.1.259 149 2/20/2024
2.1.258 356 2/20/2024
2.1.257 188 2/20/2024
2.1.256 246 2/19/2024
2.1.255 390 2/19/2024
2.1.254 71 2/19/2024
2.1.253 587 2/17/2024
2.1.252 69 2/17/2024
2.1.251 235 2/17/2024
2.1.250 352 2/16/2024
2.1.249 67 2/16/2024
2.1.248 268 2/16/2024
2.1.247 236 2/16/2024
2.1.246 71 2/16/2024
2.1.245 276 2/16/2024
2.1.244 68 2/16/2024
2.1.243 72 2/16/2024
2.1.242 291 2/16/2024
2.1.241 76 2/16/2024
2.1.240 875 2/13/2024
2.1.239 76 2/13/2024
2.1.238 490 2/13/2024
2.1.237 354 2/13/2024
2.1.236 162 2/13/2024
2.1.235 70 2/13/2024
2.1.234 133 2/13/2024
2.1.233 362 2/13/2024
2.1.232 86 2/13/2024
2.1.231 462 2/12/2024
2.1.230 311 2/12/2024
2.1.229 99 2/11/2024
2.1.228 87 2/11/2024
2.1.227 459 2/11/2024
2.1.226 214 2/11/2024
2.1.225 284 2/11/2024
2.1.224 181 2/11/2024
2.1.223 708 2/10/2024
2.1.222 143 2/10/2024
2.1.221 205 2/9/2024
2.1.220 245 2/9/2024
2.1.219 409 2/9/2024
2.1.218 288 2/9/2024
2.1.217 342 2/9/2024
2.1.216 76 2/9/2024
2.1.215 257 2/8/2024
2.1.214 346 2/8/2024
2.1.213 86 2/8/2024
2.1.212 276 2/8/2024
2.1.211 126 2/8/2024
2.1.210 427 2/8/2024
2.1.209 109 2/8/2024
2.1.208 523 2/7/2024
2.1.207 90 2/7/2024
2.1.206 124 2/7/2024
2.1.205 358 2/7/2024
2.1.204 236 2/7/2024
2.1.203 84 2/7/2024
2.1.202 242 2/7/2024
2.1.201 83 2/7/2024
2.1.200 366 2/6/2024
2.1.199 73 2/6/2024
2.1.198 673 2/5/2024
2.1.197 74 2/5/2024
2.1.196 422 2/4/2024
2.1.195 137 2/4/2024
2.1.194 617 2/2/2024
2.1.193 75 2/2/2024
2.1.192 565 1/31/2024
2.1.191 82 1/31/2024
2.1.190 437 1/30/2024
2.1.189 381 1/29/2024
2.1.188 292 1/29/2024
2.1.187 73 1/29/2024
2.1.186 73 1/29/2024
2.1.185 353 1/29/2024
2.1.184 240 1/29/2024
2.1.183 67 1/29/2024
2.1.182 236 1/28/2024
2.1.181 77 1/28/2024
2.1.180 167 1/28/2024
2.1.179 332 1/28/2024
2.1.178 74 1/28/2024
2.1.177 186 1/28/2024
2.1.176 224 1/28/2024
2.1.175 75 1/28/2024
2.1.174 568 1/28/2024
2.1.173 126 1/27/2024
2.1.172 73 1/27/2024
2.1.171 403 1/27/2024
2.1.170 75 1/27/2024
2.1.169 163 1/27/2024
2.1.168 82 1/27/2024
2.1.167 372 1/27/2024
2.1.166 74 1/27/2024
2.1.165 408 1/27/2024
2.1.164 77 1/27/2024
2.1.163 170 1/27/2024
2.1.162 97 1/26/2024
2.1.161 70 1/26/2024
2.1.160 548 1/26/2024
2.1.159 69 1/26/2024
2.1.158 374 1/26/2024
2.1.157 68 1/26/2024
2.1.156 167 1/26/2024
2.1.155 171 1/26/2024
2.1.154 74 1/26/2024
2.1.153 131 1/26/2024
2.1.152 68 1/26/2024
2.1.151 525 1/25/2024
2.1.150 79 1/25/2024
2.1.149 253 1/25/2024
2.1.148 76 1/25/2024
2.1.147 475 1/25/2024
2.1.146 143 1/25/2024
2.1.145 73 1/25/2024
2.1.144 233 1/25/2024
2.1.143 640 1/19/2024
2.1.142 75 1/19/2024
2.1.141 547 1/15/2024
2.1.140 106 1/15/2024
2.1.139 82 1/15/2024
2.1.138 463 1/15/2024
2.1.137 84 1/15/2024
2.1.136 214 1/15/2024
2.1.135 76 1/15/2024
2.1.134 347 1/15/2024
2.1.133 207 1/15/2024
2.1.132 631 1/14/2024
2.1.131 77 1/14/2024
2.1.130 483 1/13/2024
2.1.129 78 1/13/2024
2.1.128 503 1/12/2024
2.1.127 79 1/12/2024
2.1.126 485 1/11/2024
2.1.125 350 1/11/2024
2.1.124 605 1/8/2024
2.1.123 255 1/7/2024
2.1.122 454 1/5/2024
2.1.121 217 1/5/2024
2.1.120 82 1/5/2024
2.1.119 368 1/5/2024
2.1.118 352 1/5/2024
2.1.117 87 1/5/2024
2.1.116 554 1/3/2024
2.1.115 109 1/3/2024
2.1.114 334 1/1/2024
2.1.113 135 1/1/2024
2.1.112 638 12/30/2023
2.1.111 220 12/28/2023
2.1.110 165 12/28/2023
2.1.109 216 12/28/2023
2.1.108 182 12/28/2023
2.1.107 106 12/28/2023
2.1.106 421 12/28/2023
2.1.105 163 12/27/2023
2.1.104 97 12/27/2023
2.1.103 114 12/27/2023
2.1.102 89 12/27/2023
2.1.101 562 12/25/2023
2.1.100 79 12/25/2023
2.1.99 207 12/25/2023
2.1.98 96 12/25/2023
2.1.97 320 12/25/2023
2.1.96 237 12/25/2023
2.1.95 149 12/25/2023
2.1.94 93 12/25/2023
2.1.93 119 12/25/2023
2.1.92 110 12/25/2023
2.1.91 522 12/24/2023
2.1.90 174 12/24/2023
2.1.89 318 12/23/2023
2.1.88 136 12/23/2023
2.1.87 94 12/23/2023
2.1.86 205 12/23/2023
2.1.85 91 12/23/2023
2.1.84 326 12/23/2023
2.1.83 88 12/23/2023
2.1.82 361 12/23/2023
2.1.81 96 12/23/2023
2.1.80 197 12/23/2023
2.1.79 435 12/19/2023
2.1.78 89 12/19/2023
2.1.77 165 12/19/2023
2.1.76 782 12/11/2023
2.1.75 207 12/11/2023
2.1.74 219 12/10/2023
2.1.73 165 12/10/2023
2.1.72 119 12/10/2023
2.1.71 395 12/10/2023
2.1.70 134 12/9/2023
2.1.69 185 12/9/2023
2.1.68 206 12/9/2023
2.1.67 117 12/9/2023
2.1.66 131 12/9/2023
2.1.65 185 12/9/2023
2.1.64 97 12/9/2023
2.1.63 279 12/9/2023
2.1.62 395 12/6/2023
2.1.61 164 12/6/2023
2.1.60 185 12/6/2023
2.1.59 135 12/6/2023
2.1.58 221 12/5/2023
2.1.57 199 12/5/2023
2.1.56 142 12/5/2023
2.1.55 168 12/5/2023
2.1.54 159 12/5/2023
2.1.53 115 12/5/2023
2.1.52 173 12/5/2023
2.1.51 123 12/4/2023
2.1.50 103 12/4/2023
2.1.49 329 12/4/2023
2.1.48 102 12/4/2023
2.1.47 96 12/4/2023
2.1.46 303 11/28/2023
2.1.45 123 11/27/2023
2.1.44 151 11/27/2023
2.1.43 114 11/26/2023
2.1.42 188 11/23/2023
2.1.41 106 11/23/2023
2.1.40 238 11/23/2023
2.1.39 214 11/23/2023
2.1.38 170 11/23/2023
2.1.37 114 11/23/2023
2.1.36 141 11/23/2023
2.1.35 330 11/22/2023
2.1.34 137 11/20/2023
2.1.33 152 11/20/2023
2.1.32 194 11/20/2023
2.1.31 103 11/20/2023
2.1.30 205 11/19/2023
2.1.29 100 11/19/2023
2.1.28 131 11/19/2023
2.1.27 106 11/19/2023
2.1.26 176 11/19/2023
2.1.25 106 11/19/2023
2.1.24 115 11/19/2023
2.1.23 104 11/19/2023
2.1.22 98 11/19/2023
2.1.21 219 11/18/2023
2.1.20 117 11/18/2023
2.1.19 109 11/18/2023
2.1.18 104 11/18/2023
2.1.17 93 11/18/2023
2.1.16 112 11/17/2023
2.1.15 99 11/17/2023
2.1.14 107 11/17/2023
2.1.13 111 11/17/2023
2.1.12 131 11/17/2023
2.1.11 90 11/17/2023
2.1.10 106 11/17/2023
2.1.9 107 11/17/2023
2.1.8 118 11/17/2023
2.1.7 113 11/17/2023
2.1.6 135 11/17/2023
2.1.5 107 11/17/2023
2.1.4 111 11/16/2023
2.1.3 107 11/16/2023
2.0.37 545 11/15/2023
2.0.36 105 11/15/2023
2.0.35 106 11/15/2023
2.0.34 107 11/15/2023
1.0.33 109 11/14/2023
1.0.32 97 11/14/2023
1.0.31 269 11/13/2023
1.0.30 96 11/13/2023
1.0.29 126 11/10/2023
1.0.28 102 11/10/2023
1.0.27 97 11/9/2023
1.0.26 101 11/9/2023
1.0.25 100 11/9/2023
1.0.24 101 11/7/2023
1.0.23 99 11/7/2023
1.0.22 96 11/6/2023
1.0.21 105 11/6/2023
1.0.20 119 11/3/2023
1.0.19 110 11/3/2023
1.0.18 120 11/2/2023
1.0.17 108 11/2/2023
1.0.16 117 11/1/2023
1.0.15 109 11/1/2023
1.0.14 138 10/26/2023
1.0.13 121 10/26/2023
1.0.12 143 10/19/2023
1.0.11 137 10/19/2023
1.0.10 134 10/18/2023
1.0.9 135 10/18/2023
1.0.8 135 10/17/2023
1.0.7 122 10/17/2023
1.0.6 154 10/16/2023
1.0.5 150 10/16/2023
1.0.4 150 10/13/2023
1.0.3 143 10/13/2023
1.0.2 142 10/12/2023
1.0.1 161 10/1/2023