pub struct CachePolicy {
pub s_maxage: u32,
pub swr: u32,
}Expand description
Per-page Cache-Control knobs.
Both fields are seconds, both optional at the entry level — when
absent we fall back to the manifest-wide Manifest::default_cache.
§Examples
use ssg_core::CachePolicy;
let policy = CachePolicy { s_maxage: 60, swr: 86_400 };
assert_eq!(
policy.to_cache_control(),
"s-maxage=60, stale-while-revalidate=86400",
);Fields§
§s_maxage: u32s-maxage — how long the CDN may serve the cached response
before considering it stale.
swr: u32stale-while-revalidate — how long the CDN may continue
serving the stale response while it revalidates in the
background.
Implementations§
Source§impl CachePolicy
impl CachePolicy
Sourcepub fn to_cache_control(&self) -> String
pub fn to_cache_control(&self) -> String
Renders the policy as a Cache-Control header value.
§Examples
use ssg_core::CachePolicy;
let policy = CachePolicy { s_maxage: 120, swr: 600 };
assert_eq!(
policy.to_cache_control(),
"s-maxage=120, stale-while-revalidate=600",
);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 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for CachePolicy
Source§impl Debug for CachePolicy
impl Debug for CachePolicy
Source§impl Default for CachePolicy
impl Default for CachePolicy
Source§impl<'de> Deserialize<'de> for CachePolicy
impl<'de> Deserialize<'de> for CachePolicy
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for CachePolicy
Source§impl PartialEq for CachePolicy
impl PartialEq for CachePolicy
Source§fn eq(&self, other: &CachePolicy) -> bool
fn eq(&self, other: &CachePolicy) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for CachePolicy
impl Serialize 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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§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
Compare self to
key and return true if they are equal.