From a3383084fb02945e72ae782097eeec3206dbf2cd Mon Sep 17 00:00:00 2001 From: Compositr Date: Mon, 4 Nov 2024 22:07:57 +1100 Subject: [PATCH] fix: do not cache non-Bytes so docs & errors don't get cached --- src/http/responses.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/http/responses.rs b/src/http/responses.rs index 1c1f051..c72a21d 100644 --- a/src/http/responses.rs +++ b/src/http/responses.rs @@ -51,7 +51,6 @@ fn send_response(mut stream: TcpStream, status: u16, body: Body) -> UnitOrBoxedE // Headers response.push_str("Server: luciders\r\n"); - response.push_str("Cache-Control: immutable, public, max-age=604800\r\n"); // CORS response.push_str("Access-Control-Allow-Origin: *\r\n"); response.push_str("Access-Control-Allow-Methods: GET\r\n"); @@ -65,7 +64,8 @@ fn send_response(mut stream: TcpStream, status: u16, body: Body) -> UnitOrBoxedE )); match &body { Body::Bytes(_, content_type) => { - response.push_str(&format!("Content-Type: {}\r\n", content_type)) + response.push_str(&format!("Content-Type: {}\r\n", content_type)); + response.push_str("Cache-Control: immutable, public, max-age=604800\r\n"); } Body::Static(_) => response.push_str("Content-Type: text/plain; charset=utf-8\r\n"), _ => {}