adding cache header

This commit is contained in:
qpismont 2024-07-16 19:14:14 +02:00
parent 2f5d8764b6
commit 3d00a5c888

View file

@ -6,6 +6,7 @@ use axum::{
response::IntoResponse, response::IntoResponse,
}; };
use futures::TryStreamExt; use futures::TryStreamExt;
use reqwest::header;
use tokio::sync::Mutex; use tokio::sync::Mutex;
use tokio_stream::Stream; use tokio_stream::Stream;
use tokio_util::bytes::Bytes; use tokio_util::bytes::Bytes;
@ -19,7 +20,7 @@ pub async fn handle_secure(
let decrypt = crypt::decryt(data, state.secret_key.clone().unwrap())?; let decrypt = crypt::decryt(data, state.secret_key.clone().unwrap())?;
let bytes = handle(decrypt, state).await?; let bytes = handle(decrypt, state).await?;
Ok(axum::body::Body::from_stream(bytes)) Ok(([(header::CACHE_CONTROL, "public, max-age=31919000")], axum::body::Body::from_stream(bytes)))
} }
pub async fn handle_unsecure( pub async fn handle_unsecure(
@ -28,7 +29,7 @@ pub async fn handle_unsecure(
) -> Result<impl IntoResponse, MyAnyhow> { ) -> Result<impl IntoResponse, MyAnyhow> {
let bytes = handle(src, state).await?; let bytes = handle(src, state).await?;
Ok(axum::body::Body::from_stream(bytes)) Ok(([(header::CACHE_CONTROL, "public, max-age=31919000")], axum::body::Body::from_stream(bytes)))
} }
async fn handle( async fn handle(