kanidmd_core/https/middleware/
caching.rsuse axum::{
body::Body,
http::{header, HeaderValue, Request},
middleware::Next,
response::Response,
};
pub async fn dont_cache_me(request: Request<Body>, next: Next) -> Response {
let mut response = next.run(request).await;
response.headers_mut().insert(
header::CACHE_CONTROL,
HeaderValue::from_static("no-store, no-cache, max-age=0"),
);
response
.headers_mut()
.insert(header::PRAGMA, HeaderValue::from_static("no-cache"));
response
}
pub async fn cache_me_short(request: Request<Body>, next: Next) -> Response {
let mut response = next.run(request).await;
response.headers_mut().insert(
header::CACHE_CONTROL,
HeaderValue::from_static("private, max-age=300"),
);
response
.headers_mut()
.insert(header::PRAGMA, HeaderValue::from_static("no-cache"));
response
}