pub enum CachePolicy {
NoStore,
NoCache,
Immutable {
max_age_secs: u32,
},
Public {
max_age_secs: u32,
stale_while_revalidate_secs: Option<u32>,
stale_if_error_secs: Option<u32>,
},
Private {
max_age_secs: u32,
},
}Expand description
Describes how a response should be cached by browsers and CDNs.
Variants§
NoStore
no-store — prohibit all caching.
NoCache
no-cache — revalidate on every request via ETag/Last-Modified.
Immutable
public, max-age=X, immutable — ideal for content-addressed URLs.
Public
public, max-age=X [, stale-while-revalidate=Y] [, stale-if-error=Z]
Fields
Private
private, max-age=X — browser-only; never cached by shared caches.
Implementations§
Source§impl CachePolicy
impl CachePolicy
Sourcepub fn to_header_value(&self) -> String
pub fn to_header_value(&self) -> String
Formats this policy as a Cache-Control header value.
Sourcepub fn tile_default() -> Self
pub fn tile_default() -> Self
Default policy for map tiles: 1 h fresh, 60 s stale-while-revalidate, 24 h stale-if-error.
Sourcepub fn metadata_default() -> Self
pub fn metadata_default() -> Self
Default policy for dataset/layer metadata: 5 min fresh, 30 s swr, 1 h sie.
Sourcepub fn static_asset() -> Self
pub fn static_asset() -> Self
Policy for static assets referenced by content hash: 1 year, immutable.
Sourcepub fn api_response() -> Self
pub fn api_response() -> Self
Policy for dynamic API responses: 60 s fresh, 10 s swr, 10 min sie.
Trait Implementations§
Source§impl Clone for CachePolicy
impl Clone for CachePolicy
Source§fn clone(&self) -> CachePolicy
fn clone(&self) -> CachePolicy
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CachePolicy
impl Debug for CachePolicy
Source§impl PartialEq for CachePolicy
impl PartialEq for CachePolicy
impl Eq for CachePolicy
impl StructuralPartialEq for CachePolicy
Auto Trait Implementations§
impl Freeze for CachePolicy
impl RefUnwindSafe for CachePolicy
impl Send for CachePolicy
impl Sync for CachePolicy
impl Unpin for CachePolicy
impl UnsafeUnpin for CachePolicy
impl UnwindSafe for CachePolicy
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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>
Converts
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>
Converts
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