Soenneker.Utils.HttpClientCache 2.1.399

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
dotnet add package Soenneker.Utils.HttpClientCache --version 2.1.399
NuGet\Install-Package Soenneker.Utils.HttpClientCache -Version 2.1.399
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.399" />
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.399
#r "nuget: Soenneker.Utils.HttpClientCache, 2.1.399"
#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.399

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

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.Blob.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 Blob storage service client operations

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.1.399 0 4/30/2024
2.1.398 17 4/29/2024
2.1.397 40 4/29/2024
2.1.396 23 4/29/2024
2.1.395 262 4/29/2024
2.1.394 154 4/29/2024
2.1.393 345 4/29/2024
2.1.392 100 4/28/2024
2.1.391 32 4/28/2024
2.1.390 364 4/28/2024
2.1.389 50 4/28/2024
2.1.388 366 4/28/2024
2.1.387 249 4/28/2024
2.1.386 33 4/28/2024
2.1.385 352 4/28/2024
2.1.384 30 4/28/2024
2.1.383 285 4/28/2024
2.1.382 31 4/28/2024
2.1.381 595 4/28/2024
2.1.380 327 4/27/2024
2.1.379 41 4/27/2024
2.1.378 37 4/27/2024
2.1.377 1,068 4/20/2024
2.1.376 568 4/20/2024
2.1.375 507 4/19/2024
2.1.374 248 4/19/2024
2.1.373 67 4/19/2024
2.1.372 979 4/19/2024
2.1.371 502 4/19/2024
2.1.370 472 4/19/2024
2.1.369 352 4/19/2024
2.1.368 117 4/18/2024
2.1.367 64 4/18/2024
2.1.366 1,113 4/15/2024
2.1.365 418 4/14/2024
2.1.364 492 4/13/2024
2.1.363 546 4/12/2024
2.1.362 66 4/12/2024
2.1.361 444 4/12/2024
2.1.360 254 4/12/2024
2.1.359 412 4/12/2024
2.1.358 68 4/12/2024
2.1.357 683 4/12/2024
2.1.356 88 4/12/2024
2.1.355 721 4/12/2024
2.1.354 68 4/12/2024
2.1.353 296 4/11/2024
2.1.352 445 4/11/2024
2.1.351 72 4/11/2024
2.1.350 597 4/10/2024
2.1.349 67 4/10/2024
2.1.348 589 4/9/2024
2.1.347 71 4/9/2024
2.1.346 1,268 4/2/2024
2.1.345 219 4/2/2024
2.1.344 279 4/1/2024
2.1.343 100 4/1/2024
2.1.342 800 3/29/2024
2.1.341 77 3/29/2024
2.1.340 663 3/25/2024
2.1.339 64 3/25/2024
2.1.338 546 3/25/2024
2.1.337 806 3/20/2024
2.1.336 84 3/20/2024
2.1.335 887 3/19/2024
2.1.334 82 3/19/2024
2.1.333 323 3/19/2024
2.1.332 328 3/19/2024
2.1.331 536 3/18/2024
2.1.330 76 3/18/2024
2.1.329 551 3/18/2024
2.1.328 586 3/16/2024
2.1.327 325 3/15/2024
2.1.326 698 3/13/2024
2.1.325 404 3/13/2024
2.1.324 121 3/13/2024
2.1.323 97 3/13/2024
2.1.322 522 3/13/2024
2.1.321 84 3/13/2024
2.1.320 301 3/13/2024
2.1.319 68 3/13/2024
2.1.318 65 3/13/2024
2.1.317 322 3/12/2024
2.1.316 79 3/12/2024
2.1.315 371 3/12/2024
2.1.314 448 3/12/2024
2.1.313 481 3/12/2024
2.1.312 317 3/11/2024
2.1.311 664 3/11/2024
2.1.310 261 3/11/2024
2.1.309 523 3/10/2024
2.1.308 77 3/10/2024
2.1.307 667 3/8/2024
2.1.306 179 3/8/2024
2.1.305 421 3/8/2024
2.1.304 54 3/8/2024
2.1.303 444 3/8/2024
2.1.302 61 3/8/2024
2.1.301 795 3/6/2024
2.1.300 84 3/6/2024
2.1.299 722 3/4/2024
2.1.298 400 3/4/2024
2.1.297 330 3/4/2024
2.1.296 90 3/4/2024
2.1.295 875 3/3/2024
2.1.294 163 3/2/2024
2.1.293 434 3/2/2024
2.1.292 81 3/2/2024
2.1.291 1,497 2/29/2024
2.1.290 299 2/29/2024
2.1.289 71 2/29/2024
2.1.288 165 2/29/2024
2.1.287 67 2/29/2024
2.1.286 504 2/29/2024
2.1.285 978 2/26/2024
2.1.284 74 2/26/2024
2.1.283 414 2/25/2024
2.1.282 144 2/25/2024
2.1.281 653 2/23/2024
2.1.280 371 2/23/2024
2.1.279 375 2/22/2024
2.1.278 182 2/22/2024
2.1.277 269 2/22/2024
2.1.276 83 2/22/2024
2.1.275 174 2/21/2024
2.1.274 86 2/21/2024
2.1.273 434 2/21/2024
2.1.272 94 2/21/2024
2.1.271 75 2/21/2024
2.1.270 465 2/21/2024
2.1.269 229 2/21/2024
2.1.268 83 2/21/2024
2.1.267 201 2/21/2024
2.1.266 73 2/21/2024
2.1.265 221 2/21/2024
2.1.264 77 2/21/2024
2.1.263 336 2/21/2024
2.1.262 419 2/20/2024
2.1.261 273 2/20/2024
2.1.260 109 2/20/2024
2.1.259 147 2/20/2024
2.1.258 354 2/20/2024
2.1.257 186 2/20/2024
2.1.256 244 2/19/2024
2.1.255 388 2/19/2024
2.1.254 69 2/19/2024
2.1.253 585 2/17/2024
2.1.252 67 2/17/2024
2.1.251 233 2/17/2024
2.1.250 350 2/16/2024
2.1.249 65 2/16/2024
2.1.248 266 2/16/2024
2.1.247 234 2/16/2024
2.1.246 69 2/16/2024
2.1.245 274 2/16/2024
2.1.244 66 2/16/2024
2.1.243 70 2/16/2024
2.1.242 289 2/16/2024
2.1.241 74 2/16/2024
2.1.240 873 2/13/2024
2.1.239 74 2/13/2024
2.1.238 488 2/13/2024
2.1.237 352 2/13/2024
2.1.236 160 2/13/2024
2.1.235 69 2/13/2024
2.1.234 131 2/13/2024
2.1.233 360 2/13/2024
2.1.232 85 2/13/2024
2.1.231 460 2/12/2024
2.1.230 309 2/12/2024
2.1.229 97 2/11/2024
2.1.228 85 2/11/2024
2.1.227 457 2/11/2024
2.1.226 213 2/11/2024
2.1.225 282 2/11/2024
2.1.224 179 2/11/2024
2.1.223 706 2/10/2024
2.1.222 141 2/10/2024
2.1.221 203 2/9/2024
2.1.220 243 2/9/2024
2.1.219 407 2/9/2024
2.1.218 286 2/9/2024
2.1.217 340 2/9/2024
2.1.216 74 2/9/2024
2.1.215 254 2/8/2024
2.1.214 344 2/8/2024
2.1.213 84 2/8/2024
2.1.212 274 2/8/2024
2.1.211 124 2/8/2024
2.1.210 425 2/8/2024
2.1.209 107 2/8/2024
2.1.208 521 2/7/2024
2.1.207 88 2/7/2024
2.1.206 122 2/7/2024
2.1.205 353 2/7/2024
2.1.204 234 2/7/2024
2.1.203 82 2/7/2024
2.1.202 240 2/7/2024
2.1.201 81 2/7/2024
2.1.200 364 2/6/2024
2.1.199 71 2/6/2024
2.1.198 671 2/5/2024
2.1.197 72 2/5/2024
2.1.196 420 2/4/2024
2.1.195 135 2/4/2024
2.1.194 615 2/2/2024
2.1.193 73 2/2/2024
2.1.192 564 1/31/2024
2.1.191 80 1/31/2024
2.1.190 435 1/30/2024
2.1.189 379 1/29/2024
2.1.188 290 1/29/2024
2.1.187 71 1/29/2024
2.1.186 71 1/29/2024
2.1.185 351 1/29/2024
2.1.184 238 1/29/2024
2.1.183 65 1/29/2024
2.1.182 234 1/28/2024
2.1.181 75 1/28/2024
2.1.180 165 1/28/2024
2.1.179 330 1/28/2024
2.1.178 72 1/28/2024
2.1.177 184 1/28/2024
2.1.176 222 1/28/2024
2.1.175 73 1/28/2024
2.1.174 566 1/28/2024
2.1.173 124 1/27/2024
2.1.172 71 1/27/2024
2.1.171 401 1/27/2024
2.1.170 73 1/27/2024
2.1.169 161 1/27/2024
2.1.168 80 1/27/2024
2.1.167 370 1/27/2024
2.1.166 72 1/27/2024
2.1.165 406 1/27/2024
2.1.164 75 1/27/2024
2.1.163 168 1/27/2024
2.1.162 95 1/26/2024
2.1.161 68 1/26/2024
2.1.160 546 1/26/2024
2.1.159 67 1/26/2024
2.1.158 372 1/26/2024
2.1.157 66 1/26/2024
2.1.156 165 1/26/2024
2.1.155 169 1/26/2024
2.1.154 72 1/26/2024
2.1.153 129 1/26/2024
2.1.152 66 1/26/2024
2.1.151 523 1/25/2024
2.1.150 77 1/25/2024
2.1.149 251 1/25/2024
2.1.148 74 1/25/2024
2.1.147 473 1/25/2024
2.1.146 141 1/25/2024
2.1.145 71 1/25/2024
2.1.144 231 1/25/2024
2.1.143 638 1/19/2024
2.1.142 73 1/19/2024
2.1.141 545 1/15/2024
2.1.140 104 1/15/2024
2.1.139 80 1/15/2024
2.1.138 461 1/15/2024
2.1.137 82 1/15/2024
2.1.136 212 1/15/2024
2.1.135 74 1/15/2024
2.1.134 345 1/15/2024
2.1.133 205 1/15/2024
2.1.132 626 1/14/2024
2.1.131 75 1/14/2024
2.1.130 481 1/13/2024
2.1.129 76 1/13/2024
2.1.128 501 1/12/2024
2.1.127 77 1/12/2024
2.1.126 480 1/11/2024
2.1.125 348 1/11/2024
2.1.124 603 1/8/2024
2.1.123 253 1/7/2024
2.1.122 452 1/5/2024
2.1.121 215 1/5/2024
2.1.120 80 1/5/2024
2.1.119 366 1/5/2024
2.1.118 350 1/5/2024
2.1.117 85 1/5/2024
2.1.116 552 1/3/2024
2.1.115 107 1/3/2024
2.1.114 332 1/1/2024
2.1.113 133 1/1/2024
2.1.112 636 12/30/2023
2.1.111 218 12/28/2023
2.1.110 163 12/28/2023
2.1.109 214 12/28/2023
2.1.108 180 12/28/2023
2.1.107 104 12/28/2023
2.1.106 419 12/28/2023
2.1.105 160 12/27/2023
2.1.104 94 12/27/2023
2.1.103 112 12/27/2023
2.1.102 87 12/27/2023
2.1.101 560 12/25/2023
2.1.100 77 12/25/2023
2.1.99 205 12/25/2023
2.1.98 94 12/25/2023
2.1.97 318 12/25/2023
2.1.96 235 12/25/2023
2.1.95 147 12/25/2023
2.1.94 91 12/25/2023
2.1.93 117 12/25/2023
2.1.92 108 12/25/2023
2.1.91 520 12/24/2023
2.1.90 172 12/24/2023
2.1.89 316 12/23/2023
2.1.88 134 12/23/2023
2.1.87 92 12/23/2023
2.1.86 203 12/23/2023
2.1.85 89 12/23/2023
2.1.84 324 12/23/2023
2.1.83 86 12/23/2023
2.1.82 359 12/23/2023
2.1.81 94 12/23/2023
2.1.80 195 12/23/2023
2.1.79 433 12/19/2023
2.1.78 87 12/19/2023
2.1.77 163 12/19/2023
2.1.76 780 12/11/2023
2.1.75 205 12/11/2023
2.1.74 217 12/10/2023
2.1.73 163 12/10/2023
2.1.72 117 12/10/2023
2.1.71 393 12/10/2023
2.1.70 132 12/9/2023
2.1.69 183 12/9/2023
2.1.68 204 12/9/2023
2.1.67 115 12/9/2023
2.1.66 129 12/9/2023
2.1.65 183 12/9/2023
2.1.64 94 12/9/2023
2.1.63 276 12/9/2023
2.1.62 392 12/6/2023
2.1.61 161 12/6/2023
2.1.60 182 12/6/2023
2.1.59 133 12/6/2023
2.1.58 219 12/5/2023
2.1.57 197 12/5/2023
2.1.56 140 12/5/2023
2.1.55 166 12/5/2023
2.1.54 157 12/5/2023
2.1.53 113 12/5/2023
2.1.52 171 12/5/2023
2.1.51 121 12/4/2023
2.1.50 101 12/4/2023
2.1.49 327 12/4/2023
2.1.48 100 12/4/2023
2.1.47 94 12/4/2023
2.1.46 301 11/28/2023
2.1.45 121 11/27/2023
2.1.44 149 11/27/2023
2.1.43 112 11/26/2023
2.1.42 186 11/23/2023
2.1.41 104 11/23/2023
2.1.40 236 11/23/2023
2.1.39 212 11/23/2023
2.1.38 168 11/23/2023
2.1.37 112 11/23/2023
2.1.36 139 11/23/2023
2.1.35 328 11/22/2023
2.1.34 135 11/20/2023
2.1.33 150 11/20/2023
2.1.32 192 11/20/2023
2.1.31 101 11/20/2023
2.1.30 203 11/19/2023
2.1.29 98 11/19/2023
2.1.28 129 11/19/2023
2.1.27 104 11/19/2023
2.1.26 174 11/19/2023
2.1.25 104 11/19/2023
2.1.24 113 11/19/2023
2.1.23 102 11/19/2023
2.1.22 96 11/19/2023
2.1.21 217 11/18/2023
2.1.20 115 11/18/2023
2.1.19 107 11/18/2023
2.1.18 102 11/18/2023
2.1.17 91 11/18/2023
2.1.16 110 11/17/2023
2.1.15 97 11/17/2023
2.1.14 105 11/17/2023
2.1.13 109 11/17/2023
2.1.12 129 11/17/2023
2.1.11 88 11/17/2023
2.1.10 104 11/17/2023
2.1.9 105 11/17/2023
2.1.8 116 11/17/2023
2.1.7 111 11/17/2023
2.1.6 133 11/17/2023
2.1.5 105 11/17/2023
2.1.4 109 11/16/2023
2.1.3 105 11/16/2023
2.0.37 543 11/15/2023
2.0.36 103 11/15/2023
2.0.35 104 11/15/2023
2.0.34 105 11/15/2023
1.0.33 107 11/14/2023
1.0.32 95 11/14/2023
1.0.31 266 11/13/2023
1.0.30 94 11/13/2023
1.0.29 124 11/10/2023
1.0.28 100 11/10/2023
1.0.27 95 11/9/2023
1.0.26 99 11/9/2023
1.0.25 98 11/9/2023
1.0.24 99 11/7/2023
1.0.23 97 11/7/2023
1.0.22 94 11/6/2023
1.0.21 103 11/6/2023
1.0.20 117 11/3/2023
1.0.19 108 11/3/2023
1.0.18 116 11/2/2023
1.0.17 104 11/2/2023
1.0.16 115 11/1/2023
1.0.15 107 11/1/2023
1.0.14 136 10/26/2023
1.0.13 119 10/26/2023
1.0.12 141 10/19/2023
1.0.11 135 10/19/2023
1.0.10 132 10/18/2023
1.0.9 133 10/18/2023
1.0.8 133 10/17/2023
1.0.7 120 10/17/2023
1.0.6 152 10/16/2023
1.0.5 148 10/16/2023
1.0.4 148 10/13/2023
1.0.3 141 10/13/2023
1.0.2 140 10/12/2023
1.0.1 159 10/1/2023