pub struct CacheControl {
pub no_store: bool,
pub no_cache: bool,
pub private: bool,
pub must_revalidate: bool,
pub s_maxage: Option<u64>,
pub max_age: Option<u64>,
pub stale_if_error: Option<u64>,
}Expand description
Parsed upstream Cache-Control directives (RFC 7234 + the
stale-if-error extension, RFC 5861 section 4). Only the directives
the gateway’s shared cache acts on are captured; unknown directives
are ignored (forward-compat). The parser is hand-rolled (no new
dependency) and tolerant: a malformed delta-seconds argument is
treated as absent rather than failing the whole header, and directive
names are matched case-insensitively with optional whitespace.
Fields§
§no_store: boolno-store: the response MUST NOT be stored (a hard storage veto).
no_cache: boolno-cache: store, but revalidate before every reuse (a storage
veto in v1 — the gateway does not yet serve-then-revalidate, so
storing an entry that can never be replayed fresh is dead weight).
private: boolprivate: a shared cache MUST NOT store the response (the
gateway’s cache is shared — consumer keying does not make it
private, because the operator owns the cache, not the client).
must_revalidate: boolmust-revalidate: a stale response MUST NOT be served without
revalidation. Recorded but not yet enforced beyond blocking the
stale-while-revalidate serve path (see lookup).
s_maxage: Option<u64>s-maxage: the freshness lifetime for SHARED caches. Takes
precedence over max-age for the gateway’s shared cache (RFC
7234 section 5.2.2.9). Absent = fall back to max_age then the
configured ttl_secs.
max_age: Option<u64>max-age: the freshness lifetime for any cache. Used when
s-maxage is absent.
stale_if_error: Option<u64>stale-if-error (RFC 5861 section 4): the number of seconds PAST
expiry a stale entry may be served when the upstream returns an
error (5xx) or is unreachable. Absent/0 = no stale-on-error
serving beyond the configured stale-while-revalidate window.
Implementations§
Source§impl CacheControl
impl CacheControl
Sourcepub fn parse(headers: &HeaderMap) -> Self
pub fn parse(headers: &HeaderMap) -> Self
Parse every Cache-Control header value (RFC 7234 section 5.2.2).
Multiple values are folded; a directive appearing more than once
uses the last occurrence’s argument (matches common cache
behavior). Returns an empty CacheControl when the header is
absent or entirely unparseable — the caller then falls back to
the configured policy.
Sourcepub fn effective_max_age(&self) -> Option<u64>
pub fn effective_max_age(&self) -> Option<u64>
The effective shared-cache freshness lifetime, in seconds:
s-maxage wins over max-age (RFC 7234 section 5.2.2.9), else
None (the caller applies the configured ttl_secs).
Trait Implementations§
Source§impl Clone for CacheControl
impl Clone for CacheControl
Source§fn clone(&self) -> CacheControl
fn clone(&self) -> CacheControl
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CacheControl
impl Debug for CacheControl
Source§impl Default for CacheControl
impl Default for CacheControl
Source§fn default() -> CacheControl
fn default() -> CacheControl
Source§impl PartialEq for CacheControl
impl PartialEq for CacheControl
impl Eq for CacheControl
impl StructuralPartialEq for CacheControl
Auto Trait Implementations§
impl Freeze for CacheControl
impl RefUnwindSafe for CacheControl
impl Send for CacheControl
impl Sync for CacheControl
impl Unpin for CacheControl
impl UnwindSafe for CacheControl
Blanket Implementations§
§impl<T> AnyExt for T
impl<T> AnyExt for T
§fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
T behind reference§fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
T behind mutable reference§fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
T behind Rc pointer§fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
T behind Arc pointer§fn downcast_box<T>(this: Box<Self>) -> Result<Box<T>, Box<Self>>where
T: Any,
fn downcast_box<T>(this: Box<Self>) -> Result<Box<T>, Box<Self>>where
T: Any,
T behind Box pointer§fn downcast_move<T>(this: Self) -> Option<T>
fn downcast_move<T>(this: Self) -> Option<T>
Self to T,
useful only in generic context as a workaround for specializationSource§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,
§impl<T, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
impl<T, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
fn coerce_rc_to(self: Rc<X>) -> Rc<T>
fn coerce_box_to(self: Box<X>) -> Box<T>
fn coerce_ref_to(&self) -> &T
fn coerce_mut_to(&mut self) -> &mut T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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