Reliable.HttpClient.Caching
1.0.0
See the version list below for details.
dotnet add package Reliable.HttpClient.Caching --version 1.0.0
NuGet\Install-Package Reliable.HttpClient.Caching -Version 1.0.0
<PackageReference Include="Reliable.HttpClient.Caching" Version="1.0.0" />
<PackageVersion Include="Reliable.HttpClient.Caching" Version="1.0.0" />
<PackageReference Include="Reliable.HttpClient.Caching" />
paket add Reliable.HttpClient.Caching --version 1.0.0
#r "nuget: Reliable.HttpClient.Caching, 1.0.0"
#:package Reliable.HttpClient.Caching@1.0.0
#addin nuget:?package=Reliable.HttpClient.Caching&version=1.0.0
#tool nuget:?package=Reliable.HttpClient.Caching&version=1.0.0
Reliable.HttpClient.Caching
Intelligent HTTP response caching for Reliable.HttpClient with preset-based configuration and automatic memory management.
Why Reliable.HttpClient.Caching?
- Zero Configuration – Works out of the box with sensible defaults
- Preset-Based Setup – 6 ready-made configurations for common scenarios
- Automatic Dependencies – No need to manually register
IMemoryCache - Combined APIs – Resilience + Caching in one method call
- Performance Optimized – Smart cache keys, configurable expiry, memory-efficient
Installation
dotnet add package Reliable.HttpClient.Caching
Quick Start
Option 1: Simple Setup (Recommended)
// Zero configuration - just add resilience with caching
services.AddHttpClient<WeatherApiClient>()
.AddResilienceWithMediumTermCache<WeatherResponse>(); // 10 minutes cache
Option 2: Separate Registration
// Step 1: Add resilience
services.AddHttpClient<WeatherApiClient>()
.AddResilience();
// Step 2: Add caching (automatically registers IMemoryCache)
services.AddHttpClient<WeatherApiClient>()
.AddMediumTermCache<WeatherResponse>(); // 10 minutes cache
Option 3: Custom Configuration
services.AddHttpClient<WeatherApiClient>()
.AddResilienceWithCaching<WeatherResponse>(
resilienceOptions => resilienceOptions.Retry.MaxRetries = 5,
cacheOptions => cacheOptions.DefaultExpiry = TimeSpan.FromMinutes(15)
);
Preset-Based Configuration
Choose from ready-made cache presets for common scenarios:
// Short-term caching (1 minute) - for frequently changing data
services.AddHttpClient<ApiClient>()
.AddShortTermCache<ApiResponse>();
// Medium-term caching (10 minutes) - for moderately stable data
services.AddHttpClient<ApiClient>()
.AddMediumTermCache<ApiResponse>();
// Long-term caching (1 hour) - for stable data
services.AddHttpClient<ApiClient>()
.AddLongTermCache<ApiResponse>();
// High-performance caching (5 minutes, large cache) - for high-traffic APIs
services.AddHttpClient<ApiClient>()
.AddHighPerformanceCache<ApiResponse>();
// Configuration caching (30 minutes) - for config data
services.AddHttpClient<ConfigClient>()
.AddConfigurationCache<ConfigResponse>();
Combined Resilience + Caching
// Resilience with preset caching
services.AddHttpClient<ApiClient>()
.AddResilienceWithShortTermCache<ApiResponse>(); // 1 minute
services.AddHttpClient<ApiClient>()
.AddResilienceWithMediumTermCache<ApiResponse>(); // 10 minutes
services.AddHttpClient<ApiClient>()
.AddResilienceWithLongTermCache<ApiResponse>(); // 1 hour
// Custom resilience with preset caching
services.AddHttpClient<ApiClient>()
.AddResilienceWithCaching<ApiResponse>(
HttpClientPresets.SlowExternalApi(), // Resilience preset
CachePresets.MediumTerm // Cache preset
);
Usage
public class WeatherService
{
private readonly CachedHttpClient<WeatherResponse> _client;
public WeatherService(CachedHttpClient<WeatherResponse> client)
{
_client = client;
}
public async Task<WeatherResponse> GetWeatherAsync(string city)
{
return await _client.GetFromJsonAsync($"/weather?city={city}");
// First call hits API, subsequent calls return cached response
}
}
When to Use Which Preset?
| Scenario | Preset | Cache Duration | Example |
|---|---|---|---|
| Real-time data (prices, scores) | ShortTerm |
1 minute | Stock prices, live scores |
| Regular updates (news, feeds) | MediumTerm |
10 minutes | News articles, social feeds |
| Reference data (catalogs, lists) | LongTerm |
1 hour | Product catalogs, country lists |
| High-traffic APIs | HighPerformance |
5 min + large cache | Popular endpoints |
| App configuration | Configuration |
30 minutes | Feature flags, settings |
| File downloads | FileDownload |
2 hours | Documents, images |
Advanced Usage
For advanced scenarios like custom cache providers, detailed configuration options, and troubleshooting, see the comprehensive documentation.
License
This project is licensed under the MIT License - see the LICENSE file for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. 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. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net6.0
- Microsoft.Extensions.Caching.Abstractions (>= 9.0.8)
- Microsoft.Extensions.Caching.Memory (>= 9.0.8)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.8)
- Microsoft.Extensions.Http (>= 9.0.8)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.8)
- Microsoft.Extensions.Options (>= 9.0.8)
- Reliable.HttpClient (>= 1.0.0)
-
net8.0
- Microsoft.Extensions.Caching.Abstractions (>= 9.0.8)
- Microsoft.Extensions.Caching.Memory (>= 9.0.8)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.8)
- Microsoft.Extensions.Http (>= 9.0.8)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.8)
- Microsoft.Extensions.Options (>= 9.0.8)
- Reliable.HttpClient (>= 1.0.0)
-
net9.0
- Microsoft.Extensions.Caching.Abstractions (>= 9.0.8)
- Microsoft.Extensions.Caching.Memory (>= 9.0.8)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.8)
- Microsoft.Extensions.Http (>= 9.0.8)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.8)
- Microsoft.Extensions.Options (>= 9.0.8)
- Reliable.HttpClient (>= 1.0.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Reliable.HttpClient.Caching:
| Package | Downloads |
|---|---|
|
Planfact.AmoCrm.Client
Идиоматичный и типобезопасный .NET-клиент для интеграции с amoCRM API v4. |
|
|
Planfact.KodySu.Client
Идиоматичный и типобезопасный клиент для API kody.su v2.1 (поиск информации по телефонным номерам) с поддержкой отказоустойчивых соединений и кеширования. |
GitHub repositories
This package is not used by any popular GitHub repositories.
🎉 Stable v1.0.0 Release!
✨ New Preset-Based Configuration:
• 6 cache presets for common scenarios (ShortTerm, MediumTerm, LongTerm, HighPerformance,
Configuration, FileDownload)
• One-line setup methods: AddShortTermCache, AddMediumTermCache, AddLongTermCache, etc.
• Combined resilience+caching methods: AddResilienceWithCaching,
AddResilienceWithMediumTermCache, etc.
🚀 Zero-Configuration Setup:
• Automatic IMemoryCache registration - no manual setup required
• Smart defaults covering 95% of use cases
• Reduced configuration complexity from ~10 lines to 1 line
🔧 Advanced Features:
• Memory cache and custom cache providers support
• Smart cache key generation with SHA256 hashing
• HTTP Cache-Control headers support
• Cache invalidation and management APIs
• Full .NET 6.0, 8.0, 9.0 support