HttpCachingOptions Class

Options for configuring HTTP caching behavior.

public sealed class HttpCachingOptions

Constructors

NameDescription
HttpCachingOptions()

HttpCachingOptions()

HttpCachingOptions.cs
public HttpCachingOptions()

No documentation is available.

Properties

NameDescription
MaximumResponseSizeGets 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.
OnStoreErrorGets 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).
ShouldCacheResponseGets 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).
TimeProviderGets or sets the time provider used for time-based cache operations.

MaximumResponseSize

HttpCachingOptions.cs

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.

public long? MaximumResponseSize { get; set; }

Property value

long?

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).

public Action<Exception>? OnStoreError { get; set; }

Property value

Action<Exception>?

ShouldCacheResponse

HttpCachingOptions.cs

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).

public Func<HttpResponseMessage, bool>? ShouldCacheResponse { get; set; }

Gets or sets the time provider used for time-based cache operations.

public TimeProvider TimeProvider { get; set; }

Property value

TimeProvider