From 3d00a5c88814663903f0a666b8a73d86d8d445bb Mon Sep 17 00:00:00 2001 From: qpismont Date: Tue, 16 Jul 2024 19:14:14 +0200 Subject: [PATCH] adding cache header --- src/routes.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/routes.rs b/src/routes.rs index 1b2cc10..a5632bf 100644 --- a/src/routes.rs +++ b/src/routes.rs @@ -6,6 +6,7 @@ use axum::{ response::IntoResponse, }; use futures::TryStreamExt; +use reqwest::header; use tokio::sync::Mutex; use tokio_stream::Stream; 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 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( @@ -28,7 +29,7 @@ pub async fn handle_unsecure( ) -> Result { 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(