pub struct RequestIssuer { /* private fields */ }Expand description
Identify cacheable requests by their URI.
§Caveats
The generated key is derived only from the request’s scheme, authority,
path, query, and (optionally) method. It does not include content
negotiation headers such as Accept-Encoding or Accept. If the cached
responses vary by those headers — for example when a compression middleware
also runs — a client may receive a representation encoded for a different
request (e.g. a gzip body without Accept-Encoding: gzip).
The cache stores the response produced by the handlers inside it (hoops
run outer-to-inner and the entry is captured on the way back out), so the
negotiating middleware must run outside the cache — added to the router
before the cache hoop — so it re-negotiates on every request, including
cache hits. Alternatively, use a custom CacheIssuer that folds the
relevant headers into the key.
Note that a Vary response header is not a fix here: the store never
evaluates Vary at lookup time, so a Vary response is never cached (in
either cache_private mode) — it would otherwise be replayed under the same
key regardless of the request’s negotiation headers. Fold the relevant headers
into a custom CacheIssuer key instead.
Implementations§
Source§impl RequestIssuer
impl RequestIssuer
Sourcepub fn use_scheme(self, value: bool) -> Self
pub fn use_scheme(self, value: bool) -> Self
Whether to use the request’s URI scheme when generating the key.
Whether to use the request’s URI authority when generating the key.
Sourcepub fn use_path(self, value: bool) -> Self
pub fn use_path(self, value: bool) -> Self
Whether to use the request’s URI path when generating the key.
Sourcepub fn use_query(self, value: bool) -> Self
pub fn use_query(self, value: bool) -> Self
Whether to use the request’s URI query when generating the key.
Sourcepub fn use_method(self, value: bool) -> Self
pub fn use_method(self, value: bool) -> Self
Whether to use the request method when generating the key.
Trait Implementations§
Source§impl CacheIssuer for RequestIssuer
impl CacheIssuer for RequestIssuer
Source§impl Clone for RequestIssuer
impl Clone for RequestIssuer
Source§fn clone(&self) -> RequestIssuer
fn clone(&self) -> RequestIssuer
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more