#[non_exhaustive]
pub enum CacheDirective {
Show 17 variants MaxAge(u32), MaxStale(u32), MinFresh(u32), SMaxAge(u32), NoCache, NoStore, NoTransform, OnlyIfCached, MustRevalidate, ProxyRevalidate, MustUnderstand, Private, Public, Immutable, StaleWhileRevalidate, StaleIfError, Extension(StringOption<String>),
}
Expand description

Directives contained in a CacheControl header.

Read more on MDN.

Variants (Non-exhaustive)

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.

MaxAge(u32)

The max-age=N directive.

When used as a request directive, it indicates that the client allows a stored response that is generated on the origin server within N seconds — where N may be any non-negative integer (including 0). Read more on MDN.

When used as a response directive, it indicates that the response remains fresh until N seconds after the response is generated. Read more on MDN.

MaxStale(u32)

The max-stale=N request directive.

This directive indicates that the client allows a stored response that is stale within N seconds. Read more on MDN.

MinFresh(u32)

The min-fresh=N request directive.

This directive indicates that the client allows a stored response that is fresh for at least N seconds. Read more on MDN.

SMaxAge(u32)

The s-maxage=N response directive.

This directive also indicates how long the response is fresh for (similar to max-age)—but it is specific to shared caches, and they will ignore max-age when it is present. Read more on MDN.

NoCache

The no-cache directive.

When used as a request directive, it asks caches to validate the response with the origin server before reuse. Read more on MDN.

When used as a response directive, it indicates that the response can be stored in caches, but the response must be validated with the origin server before each reuse, even when the cache is disconnected from the origin server. Read more on MDN.

NoStore

The no-store directive.

When used as a request directive, it allows a client to request that caches refrain from storing the request and corresponding response — even if the origin server’s response could be stored. Read more on MDN.

When used as a response directive, it indicates that the response can be stored in caches, but the response must be validated with the origin server before each reuse, even when the cache is disconnected from the origin server. Read more on MDN.

NoTransform

The no-transform directive.

This directive, in both request and response contexts, indicates that any intermediary (regardless of whether it implements a cache) shouldn’t transform the response contents. Read more on MDN.

OnlyIfCached

The only-if-cached request directive.

This directive indicates that caches should obtain an already-cached response. If a cache has stored a response, it’s reused. Read more on MDN.

MustRevalidate

The must-revalidate response directive.

This directive indicates that the response can be stored in caches and can be reused while fresh. If the response becomes stale, it must be validated with the origin server before reuse. Read more on MDN.

ProxyRevalidate

The proxy-revalidate response directive.

This directive is the equivalent of must-revalidate, but specifically for shared caches only. Read more on MDN.

MustUnderstand

The must-understand response directive.

This directive indicates that a cache should store the response only if it understands the requirements for caching based on status code. Read more on MDN.

Private

The private response directive.

This directive indicates that the response can be stored only in a private cache (e.g. local caches in browsers). Read more on MDN.

Public

The public response directive.

This directive indicates that the response can be stored in a shared cache. Responses for requests with Authorization header fields must not be stored in a shared cache; however, the public directive will cause such responses to be stored in a shared cache. Read more on MDN.

Immutable

The immutable response directive.

This directive indicates that the response will not be updated while it’s fresh. Read more on MDN.

StaleWhileRevalidate

The stale-while-revalidate response directive.

This directive indicates that the cache could reuse a stale response while it revalidates it to a cache. Read more on MDN.

StaleIfError

The stale-if-error directive.

When used as a response directive, it indicates that the cache can reuse a stale response when an origin server responds with an error (500, 502, 503, or 504). Read more on MDN.

Extension(StringOption<String>)

Extension directive.

An unknown directives is collected into this variant with an optional argument value.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

The associated error which can be returned from parsing.

Parses a string s to return a value of this type. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Compare self to key and return true if they are equal.

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more