HttpCachePersistenceEntry Class
Represents a persisted HTTP cache entry.
public sealed class HttpCachePersistenceEntryRemarks
This type is part of IHttpCacheStore public contract. It allows custom providers to persist cache metadata without exposing internal cache implementation details.
Constructors
| Name | Description |
|---|---|
| HttpCachePersistenceEntry() |
HttpCachePersistenceEntry()
public HttpCachePersistenceEntry()No documentation is available.
Properties
| Name | Description |
|---|---|
| AgeValue | Gets or sets the age value. |
| ETag | Gets or sets the ETag validator. |
| Expires | Gets or sets the Expires header value. |
| Immutable | Gets or sets a value indicating whether immutable is set. |
| IsUnusableWhenStale | Gets a value indicating whether the entry becomes unusable as soon as it is stale. |
| LastModified | Gets or sets the Last-Modified validator. |
| MaxAge | Gets or sets the max-age directive value. |
| MustRevalidate | Gets or sets a value indicating whether must-revalidate is set. |
| NoTransform | Gets or sets a value indicating whether no-transform is set. |
| NoVarySearch | Gets or sets the canonical No-Vary-Search value of the response, or null when the response does not declare one. |
| NormalizedQuery | Gets or sets the query the response was stored for, canonicalized with HttpCachePersistenceEntry.NoVarySearch. |
| Private | Gets or sets a value indicating whether private is set. |
| ProxyRevalidate | Gets or sets a value indicating whether proxy-revalidate is set. |
| Public | Gets or sets a value indicating whether public is set. |
| RequestTime | Gets or sets the request time. |
| ResponseDate | Gets or sets the response date. |
| ResponseNoCache | Gets or sets a value indicating whether no-cache is set. |
| ResponseTime | Gets or sets the response time. |
| SecondaryKeyHeaders | Gets or sets the normalized vary-based secondary key headers. |
| SecondaryKeyMatchNone | Gets or sets a value indicating whether this entry should never match requests. Corresponds to the Vary: * behavior. |
| SerializedResponse | Gets or sets the serialized HTTP response payload. |
| SharedMaxAge | Gets or sets the s-maxage directive value. |
| StaleIfError | Gets or sets the stale-if-error value. |
AgeValue
HttpCachePersistenceEntry.csExpires
HttpCachePersistenceEntry.csImmutable
HttpCachePersistenceEntry.csIsUnusableWhenStale
HttpCachePersistenceEntry.csGets a value indicating whether the entry becomes unusable as soon as it is stale.
public bool IsUnusableWhenStale { get; }Property value
Remarks
Two things keep an entry useful past its freshness lifetime: a validator, which lets it be revalidated with a conditional request, and stale-if-error (RFC 5861), which lets it be served as-is while the origin is failing. An entry with neither can only ever be discarded once it is stale, so a store is free to reclaim it.
must-revalidate, proxy-revalidate and no-cache are deliberately not consulted. They say when a stored response must be revalidated before reuse, not whether it can be reused at all, so requiring one of them here left an ordinary max-age entry unreclaimable forever.
LastModified
HttpCachePersistenceEntry.csGets or sets the Last-Modified validator.
public DateTimeOffset? LastModified { get; set; }Property value
MustRevalidate
HttpCachePersistenceEntry.csNoTransform
HttpCachePersistenceEntry.csNoVarySearch
HttpCachePersistenceEntry.csNormalizedQuery
HttpCachePersistenceEntry.csGets or sets the query the response was stored for, canonicalized with HttpCachePersistenceEntry.NoVarySearch.
public string? NormalizedQuery { get; set; }Property value
Remarks
Only set together with HttpCachePersistenceEntry.NoVarySearch: those entries are stored under a primary key that leaves the query out, so the query belongs to their secondary key.
Private
HttpCachePersistenceEntry.csProxyRevalidate
HttpCachePersistenceEntry.csRequestTime
HttpCachePersistenceEntry.csResponseDate
HttpCachePersistenceEntry.csResponseNoCache
HttpCachePersistenceEntry.csResponseTime
HttpCachePersistenceEntry.csSecondaryKeyHeaders
HttpCachePersistenceEntry.csGets or sets the normalized vary-based secondary key headers.
public Dictionary<string, string>? SecondaryKeyHeaders { get; set; }Property value
SecondaryKeyMatchNone
HttpCachePersistenceEntry.csSerializedResponse
HttpCachePersistenceEntry.csGets or sets the serialized HTTP response payload.
public ReadOnlyMemory<byte> SerializedResponse { get; set; }Property value
StaleIfError
HttpCachePersistenceEntry.csMethods
| Name | Description |
|---|---|
| Clone() | Creates a deep clone of the current instance. |
| ComputeSecondaryKeyHash() | Computes a stable hash of the secondary key, suitable for use as a storage key. |
| GetCurrentAge(DateTimeOffset) | Computes the age of the entry at the specified time, as defined by RFC 7234 Section 4.2.3. |
| GetFreshnessLifetime() | Computes the freshness lifetime of the entry, as defined by RFC 7234 Section 4.2.1. |
| GetStaleTime() | Gets the time at which the entry becomes stale. |
| HasSameSecondaryKey(HttpCachePersistenceEntry, HttpCachePersistenceEntry) | Indicates whether two entries share the same secondary key. |
| IsObsolete(DateTimeOffset) | Indicates whether the entry is stale and cannot be reused, and can therefore be removed by a store. |
Clone()
HttpCachePersistenceEntry.csComputeSecondaryKeyHash()
HttpCachePersistenceEntry.csComputes a stable hash of the secondary key, suitable for use as a storage key.
public string ComputeSecondaryKeyHash()Returns
Remarks
Two entries that HttpCachePersistenceEntry.HasSameSecondaryKey considers the same have the same hash, whatever the comparer of their HttpCachePersistenceEntry.SecondaryKeyHeaders.
GetCurrentAge(DateTimeOffset)
HttpCachePersistenceEntry.csComputes the age of the entry at the specified time, as defined by RFC 7234 Section 4.2.3.
public TimeSpan GetCurrentAge(DateTimeOffset now)GetFreshnessLifetime()
HttpCachePersistenceEntry.csGetStaleTime()
HttpCachePersistenceEntry.csGets the time at which the entry becomes stale.
public DateTimeOffset GetStaleTime()Returns
Remarks
The result is clamped to the range of DateTimeOffset. Stores can index this value to remove obsolete entries without deserializing them.
HasSameSecondaryKey(HttpCachePersistenceEntry, HttpCachePersistenceEntry)
HttpCachePersistenceEntry.csIndicates whether two entries share the same secondary key.
public static bool HasSameSecondaryKey(HttpCachePersistenceEntry left, HttpCachePersistenceEntry right)Parameters
Returns
Remarks
Header names are compared case-insensitively (RFC 9110 Section 5.1) whatever the comparer of the HttpCachePersistenceEntry.SecondaryKeyHeaders: a store that deserializes an entry gets a case-sensitive dictionary.
IsObsolete(DateTimeOffset)
HttpCachePersistenceEntry.csIndicates whether the entry is stale and cannot be reused, and can therefore be removed by a store.
public bool IsObsolete(DateTimeOffset now)