pub struct Settings { /* private fields */ }
Expand description
The rules for handling and caching a request/response.
Implementations§
source§impl Settings
impl Settings
sourcepub fn empty() -> Self
pub fn empty() -> Self
Returns an empty set of rules. Will not cache any variants, except compressed.
sourcepub fn add_rule(
self,
request_header: &'static str,
transformation: impl Fn(&str) -> Cow<'static, str> + Send + Sync + 'static,
default: &'static str
) -> Self
pub fn add_rule( self, request_header: &'static str, transformation: impl Fn(&str) -> Cow<'static, str> + Send + Sync + 'static, default: &'static str ) -> Self
Add a custom rule.
The request_header
is used when outputting the vary
header
and for the internal cache.
transformation
takes request_header
and (hopefully, for performance)
narrows the variants down to a finite number.
Prefer to return a limited set of strings from the transformation to minimize cache size. If you generate
String
s, limit the amount of different strings.
If you have a large set or infinitely many variants outputted by transformation
,
the cache will suffer. Consider disabling the cache for the files affected by this rule
to improve performance.
Panics
Will panic if the request_header
contains invalid bytes.
All of the bytes must satisfy b >= 32 && b < 127 || b == b'\t'
where b is a byte.
See utils::is_valid_header_value_byte
.