From 08595c6f14a89df1559974e8835e63881a1a9601 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Fri, 18 Oct 2024 00:12:07 +0200 Subject: [PATCH] fix: cache js static assets by default --- backend/windmill-api/src/static_assets.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/windmill-api/src/static_assets.rs b/backend/windmill-api/src/static_assets.rs index aa9870907e..783732b1c0 100644 --- a/backend/windmill-api/src/static_assets.rs +++ b/backend/windmill-api/src/static_assets.rs @@ -48,7 +48,10 @@ fn serve_path(path: &str) -> Response { let mut res = Response::builder() .header(header::CONTENT_TYPE, mime.as_ref()) .header(header::ACCESS_CONTROL_ALLOW_ORIGIN, "*"); - if mime.as_ref() == mime::APPLICATION_JAVASCRIPT || path.ends_with(".wasm") { + if mime.as_ref() == mime::APPLICATION_JAVASCRIPT + || mime.as_ref() == mime::TEXT_JAVASCRIPT + || path.ends_with(".wasm") + { res = res.header(header::CACHE_CONTROL, "max-age=31536000"); } else if (mime.type_(), mime.subtype()) == (mime::TEXT, mime::CSS) { res = res.header(header::CACHE_CONTROL, "max-age=31536000");