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§
Source§impl CacheControl
impl CacheControl
Sourcepub fn from_value(value: &str) -> Option<Self>
pub fn from_value(value: &str) -> Option<Self>
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)));
Sourcepub fn from_header(value: &str) -> Option<Self>
pub fn from_header(value: &str) -> Option<Self>
Parses a Cache-Control header.