From d982c5fe48ec75bfdcd8266bac61e3d868ca5b53 Mon Sep 17 00:00:00 2001 From: Kevin Midboe Date: Sat, 4 Nov 2023 21:44:00 +0100 Subject: [PATCH] Cache-control headers for all requests --- nginx.conf | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/nginx.conf b/nginx.conf index 8bd856d..45f6112 100644 --- a/nginx.conf +++ b/nginx.conf @@ -6,6 +6,14 @@ http { include mime.types; sendfile on; + map $sent_http_content_type $cacheable_types { + "text/html" "max-age=86400"; # 1 day + "application/javascript" "max-age=31536000"; # 1 year + "text/css" "max-age=31536000"; + "image/jpeg" "max-age=31536000"; + default "max-age=2592000"; # 30 days + } + server { listen 80; listen [::]:80; @@ -17,5 +25,9 @@ http { root /app/; gzip_static on; + + location / { + add_header "Cache-Control" $cacheable_types; + } } }