Class ResponseCache
Captures the content of an HttpResponseMessage for caching.
public sealed class ResponseCache
- Inheritance
-
objectResponseCache
Properties
IsExpired
Indicates whether this cached response has expired.
public bool IsExpired { get; }
Property Value
Methods
From(HttpResponseMessage)
Creates a ResponseCache from a response if it is eligible for caching.
public static ResponseCache? From(HttpResponseMessage response)
Parameters
responseHttpResponseMessage
Returns
- ResponseCache
The ResponseCache;
nullif the response is not eligible for caching.
GetContent()
Returns a new HttpContent backed by the cached bytes.
public HttpContent GetContent()
Returns
Remarks
Each call produces an independent copy so the body can be consumed multiple times.
SetIfModifiedHeaders(HttpRequestHeaders)
Sets request headers asserting that the resource has been modified since it was cached.
public void SetIfModifiedHeaders(HttpRequestHeaders headers)
Parameters
headersHttpRequestHeaders
Remarks
Suitable for GET/HEAD requests that should bypass the cache.
SetIfUnmodifiedHeaders(HttpRequestHeaders)
Sets request headers asserting that the resource has not been modified since it was cached.
public void SetIfUnmodifiedHeaders(HttpRequestHeaders headers)
Parameters
headersHttpRequestHeaders
Remarks
Suitable for PUT/DELETE requests to prevent lost updates.