pub struct ResponseCache { /* private fields */ }Expand description
Cache middleware, see the module documentation. Cloning gives another handle to the same cache.
Implementations§
Source§impl ResponseCache
impl ResponseCache
pub fn new() -> Self
Sourcepub fn ttl(self, ttl: Duration) -> Self
pub fn ttl(self, ttl: Duration) -> Self
Lifetime of responses that do not say otherwise (default 60 seconds)
Sourcepub fn stale_while_revalidate(self, window: Duration) -> Self
pub fn stale_while_revalidate(self, window: Duration) -> Self
Serve an expired response for this long while one request refreshes it in the background (default off)
Sourcepub fn max_entries(self, max: usize) -> Self
pub fn max_entries(self, max: usize) -> Self
Most cached responses (default 1000); the oldest go first
Sourcepub fn statuses<I: IntoIterator<Item = u16>>(self, statuses: I) -> Self
pub fn statuses<I: IntoIterator<Item = u16>>(self, statuses: I) -> Self
Status codes worth caching (default only 200)
Sourcepub fn vary_by<I, S>(self, headers: I) -> Self
pub fn vary_by<I, S>(self, headers: I) -> Self
Request headers that change the response (Accept-Language, …): each
distinct value gets its own entry, and Vary is added to the response
Sourcepub fn per_user(self) -> Self
pub fn per_user(self) -> Self
Cache requests that carry Authorization or Cookie too, with a separate
entry per credential. Only for responses that depend on nothing but the
credential itself.
Sourcepub fn invalidate_prefix(&self, prefix: &str)
pub fn invalidate_prefix(&self, prefix: &str)
Drop every cached response whose path starts with prefix
pub fn is_empty(&self) -> bool
Trait Implementations§
Source§impl Clone for ResponseCache
impl Clone for ResponseCache
Source§impl Default for ResponseCache
impl Default for ResponseCache
Auto Trait Implementations§
impl Freeze for ResponseCache
impl RefUnwindSafe for ResponseCache
impl Send for ResponseCache
impl Sync for ResponseCache
impl Unpin for ResponseCache
impl UnsafeUnpin for ResponseCache
impl UnwindSafe for ResponseCache
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