kanidmd_core/https/middleware/
caching.rs
1use axum::{
2 body::Body,
3 http::{header, HeaderValue, Request},
4 middleware::Next,
5 response::Response,
6};
7
8pub async fn dont_cache_me(request: Request<Body>, next: Next) -> Response {
10 let mut response = next.run(request).await;
11 response.headers_mut().insert(
12 header::CACHE_CONTROL,
13 HeaderValue::from_static("no-store, no-cache, max-age=0"),
14 );
15 response
16 .headers_mut()
17 .insert(header::PRAGMA, HeaderValue::from_static("no-cache"));
18
19 response
20}
21
22pub async fn cache_me_short(request: Request<Body>, next: Next) -> Response {
24 let mut response = next.run(request).await;
25 response.headers_mut().insert(
26 header::CACHE_CONTROL,
27 HeaderValue::from_static("private, max-age=300"),
28 );
29 response
30 .headers_mut()
31 .insert(header::PRAGMA, HeaderValue::from_static("no-cache"));
32
33 response
34}