pub struct CacheControlConfig {
pub cache_control: String,
pub vary: Vec<String>,
pub set_expires: bool,
pub preserve_existing: bool,
pub methods: Vec<Method>,
pub path_patterns: Vec<String>,
pub cacheable_statuses: Vec<u16>,
}Expand description
Configuration for the Cache Control middleware.
Fields§
§cache_control: StringThe Cache-Control header value to set.
vary: Vec<String>Optional Vary header values for content negotiation.
set_expires: boolWhether to set Expires header (deprecated but still used).
preserve_existing: boolWhether to preserve existing Cache-Control headers.
methods: Vec<Method>HTTP methods to apply caching to (default: GET, HEAD).
path_patterns: Vec<String>Path patterns to match (empty = match all).
cacheable_statuses: Vec<u16>Status codes to cache (default: 200-299).
Implementations§
Source§impl CacheControlConfig
impl CacheControlConfig
Sourcepub fn from_preset(preset: CachePreset) -> Self
pub fn from_preset(preset: CachePreset) -> Self
Create configuration from a preset.
Sourcepub fn from_builder(builder: CacheControlBuilder) -> Self
pub fn from_builder(builder: CacheControlBuilder) -> Self
Create configuration from a custom builder.
Sourcepub fn cache_control(self, value: impl Into<String>) -> Self
pub fn cache_control(self, value: impl Into<String>) -> Self
Set the Cache-Control header value.
Sourcepub fn vary(self, header: impl Into<String>) -> Self
pub fn vary(self, header: impl Into<String>) -> Self
Add a Vary header value (for content negotiation).
Sourcepub fn vary_headers(self, headers: Vec<String>) -> Self
pub fn vary_headers(self, headers: Vec<String>) -> Self
Add multiple Vary header values.
Sourcepub fn with_expires(self, enable: bool) -> Self
pub fn with_expires(self, enable: bool) -> Self
Enable setting the Expires header.
Sourcepub fn preserve_existing(self, preserve: bool) -> Self
pub fn preserve_existing(self, preserve: bool) -> Self
Whether to preserve existing Cache-Control headers.
Sourcepub fn path_patterns(self, patterns: Vec<String>) -> Self
pub fn path_patterns(self, patterns: Vec<String>) -> Self
Set path patterns to match (glob-style).
Sourcepub fn cacheable_statuses(self, statuses: Vec<u16>) -> Self
pub fn cacheable_statuses(self, statuses: Vec<u16>) -> Self
Set cacheable status codes.
Trait Implementations§
Source§impl Clone for CacheControlConfig
impl Clone for CacheControlConfig
Source§fn clone(&self) -> CacheControlConfig
fn clone(&self) -> CacheControlConfig
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 CacheControlConfig
impl Debug for CacheControlConfig
Auto Trait Implementations§
impl Freeze for CacheControlConfig
impl RefUnwindSafe for CacheControlConfig
impl Send for CacheControlConfig
impl Sync for CacheControlConfig
impl Unpin for CacheControlConfig
impl UnwindSafe for CacheControlConfig
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<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).