HttpCachingOptions Class
Options for configuring HTTP caching behavior.
public sealed class HttpCachingOptionsConstructors
| Name | Description |
|---|---|
| HttpCachingOptions() |
HttpCachingOptions()
HttpCachingOptions.cspublic HttpCachingOptions()No documentation is available.
Properties
| Name | Description |
|---|---|
| CoalesceRequests | Gets or sets a value indicating whether concurrent requests for the same URL share a single request to the server. |
| IsSharedCache | Gets or sets a value indicating whether the cache follows the rules of a shared cache (RFC 9111), such as a proxy serving several users. |
| MaximumResponseSize | Gets or sets the maximum size in bytes that a response can be to be cached. Responses larger than this value will not be cached. Default is 5 MB (5,242,880 bytes). Set to null to disable size checking. |
| OnStoreError | Gets or sets a callback invoked when the cache store fails. A store failure never fails the request: the lookup is treated as a miss and the write is skipped, so a degraded store degrades to no caching rather than to a broken HttpClient. This callback is the only way to observe that, so set it if you need the failures to be visible. Default is null (store failures are silently ignored). |
| ShouldCacheResponse | Gets or sets a predicate that determines whether a response should be cached. When the predicate returns true, normal caching logic applies. When the predicate returns false, the response is not cached. Default is null (all responses that meet caching requirements are cached). |
| TimeProvider | Gets or sets the time provider used for time-based cache operations. |
CoalesceRequests
HttpCachingOptions.csGets or sets a value indicating whether concurrent requests for the same URL share a single request to the server.
public bool CoalesceRequests { get; set; }Property value
Remarks
When a request must go to the server (no stored response, or a stale one to revalidate), the concurrent requests with the same method and URL wait for it to complete, then look up the cache again. The ones the stored response can answer are served from the cache; the others, for instance because the response varies on a header they send differently, or because it could not be stored, go to the server themselves. Requests with a Range header do not take part in coalescing. Default is false.
MaximumResponseSize
HttpCachingOptions.csOnStoreError
HttpCachingOptions.csGets or sets a callback invoked when the cache store fails. A store failure never fails the request: the lookup is treated as a miss and the write is skipped, so a degraded store degrades to no caching rather than to a broken HttpClient. This callback is the only way to observe that, so set it if you need the failures to be visible. Default is null (store failures are silently ignored).
Property value
ShouldCacheResponse
HttpCachingOptions.csGets or sets a predicate that determines whether a response should be cached. When the predicate returns true, normal caching logic applies. When the predicate returns false, the response is not cached. Default is null (all responses that meet caching requirements are cached).
public Func<HttpResponseMessage, bool>? ShouldCacheResponse { get; set; }Property value
TimeProvider
HttpCachingOptions.csGets or sets the time provider used for time-based cache operations.
public TimeProvider TimeProvider { get; set; }