Struct cache_control::CacheControl[][src]

pub struct CacheControl {
    pub cachability: Option<Cachability>,
    pub max_age: Option<Duration>,
    pub s_max_age: Option<Duration>,
    pub max_stale: Option<Duration>,
    pub min_fresh: Option<Duration>,
    pub must_revalidate: bool,
    pub proxy_revalidate: bool,
    pub immutable: bool,
    pub no_store: bool,
    pub no_transform: bool,
}
Expand description

Represents a Cache-Control header

Fields

cachability: Option<Cachability>max_age: Option<Duration>

The maximum amount of time a resource is considered fresh. Unlike Expires, this directive is relative to the time of the request.

s_max_age: Option<Duration>

Overrides max-age or the Expires header, but only for shared caches (e.g., proxies). Ignored by private caches.

max_stale: Option<Duration>

Indicates the client will accept a stale response. An optional value in seconds indicates the upper limit of staleness the client will accept.

min_fresh: Option<Duration>

Indicates the client wants a response that will still be fresh for at least the specified number of seconds.

must_revalidate: bool

Indicates that once a resource becomes stale, caches do not use their stale copy without successful validation on the origin server.

proxy_revalidate: bool

Like must-revalidate, but only for shared caches (e.g., proxies). Ignored by private caches.

immutable: bool

Indicates that the response body will not change over time.

no_store: bool

The response may not be stored in any cache.

no_transform: bool

An intermediate cache or proxy cannot edit the response body, Content-Encoding, Content-Range, or Content-Type.

Implementations

Parses the value of the Cache-Control header (i.e. everything after “Cache-Control:”).

use cache_control::{Cachability, CacheControl};
use std::time::Duration;

let cache_control = CacheControl::from_value("public, max-age=60").unwrap();
assert_eq!(cache_control.cachability, Some(Cachability::Public));
assert_eq!(cache_control.max_age, Some(Duration::from_secs(60)));

Parses a Cache-Control header.

Trait Implementations

Formats the value using the given formatter. Read more

Returns the “default value” for a 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

Performs the conversion.

Performs the conversion.

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.