blob: 0f11924e11631c57d63262864b785b221a8d805c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
use axum::extract::Request;
use axum::http::header::{HeaderValue, CACHE_CONTROL};
use axum::middleware::Next;
use axum::response::Response;
pub async fn cache_static(request: Request, next: Next) -> Response {
let was_static = request.uri().path().starts_with("/assets");
let mut response = next.run(request).await;
if was_static {
response.headers_mut().insert(CACHE_CONTROL, HeaderValue::from_static("max-age=3600"));
}
response
}
|