pub struct CacheHeaders {
pub cache_control: String,
pub etag: Option<String>,
pub last_modified: Option<String>,
pub vary: Option<String>,
pub cdn_cache_control: Option<String>,
pub surrogate_control: Option<String>,
}Expand description
A complete set of cache-related HTTP response headers.
Fields§
§cache_control: StringValue of the Cache-Control header.
etag: Option<String>Value of the ETag header, if any.
last_modified: Option<String>Value of the Last-Modified header (HTTP date), if any.
vary: Option<String>Value of the Vary header, if any.
cdn_cache_control: Option<String>Value of the CDN-Cache-Control header, if any.
surrogate_control: Option<String>Value of the Surrogate-Control header (Varnish/Fastly), if any.
Implementations§
Source§impl CacheHeaders
impl CacheHeaders
Sourcepub fn new(policy: CachePolicy) -> Self
pub fn new(policy: CachePolicy) -> Self
Creates a new CacheHeaders from a CachePolicy.
Sourcepub fn with_last_modified(self, unix_secs: u64) -> Self
pub fn with_last_modified(self, unix_secs: u64) -> Self
Attaches a Last-Modified header derived from a Unix timestamp
(builder-style).
Sourcepub fn with_vary(self, vary: VaryHeader) -> Self
pub fn with_vary(self, vary: VaryHeader) -> Self
Attaches a Vary header (builder-style).
Sourcepub fn with_cdn_override(self, cdn_max_age_secs: u32) -> Self
pub fn with_cdn_override(self, cdn_max_age_secs: u32) -> Self
Adds CDN-specific override headers (CDN-Cache-Control and
Surrogate-Control) with a custom max-age (builder-style).
Sourcepub fn is_not_modified(&self, if_none_match: Option<&str>) -> bool
pub fn is_not_modified(&self, if_none_match: Option<&str>) -> bool
Returns true if the request’s If-None-Match value matches this
response’s ETag, indicating the client’s copy is still valid (→ 304).
Sourcepub fn to_header_pairs(&self) -> Vec<(String, String)>
pub fn to_header_pairs(&self) -> Vec<(String, String)>
Returns all set headers as (name, value) pairs.
Cache-Control is always included. All other headers are omitted when
not set.
Trait Implementations§
Source§impl Clone for CacheHeaders
impl Clone for CacheHeaders
Source§fn clone(&self) -> CacheHeaders
fn clone(&self) -> CacheHeaders
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CacheHeaders
impl Debug for CacheHeaders
Source§impl Default for CacheHeaders
impl Default for CacheHeaders
Source§fn default() -> CacheHeaders
fn default() -> CacheHeaders
Auto Trait Implementations§
impl Freeze for CacheHeaders
impl RefUnwindSafe for CacheHeaders
impl Send for CacheHeaders
impl Sync for CacheHeaders
impl Unpin for CacheHeaders
impl UnsafeUnpin for CacheHeaders
impl UnwindSafe for CacheHeaders
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more