From a49aed8e11e67163e2fe43d6eb098541cedca285 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Fri, 16 May 2025 15:37:59 +0200 Subject: [PATCH] Refactor nginx config with improved caching strategy --- docker/nginx.conf | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/docker/nginx.conf b/docker/nginx.conf index 7f7313e00..d94a944b0 100644 --- a/docker/nginx.conf +++ b/docker/nginx.conf @@ -1,10 +1,3 @@ -map $sent_http_content_type $expires { - # cache everything for 1 year - default 1y; - # html files shouldn't be cached for single-page applications - text/html off; -} - server { listen 80; server_name localhost; @@ -12,24 +5,30 @@ server { # serve compressed file if filename.gz exists gzip_static on; - location /console { - root /usr/share/nginx/html; - index index.html index.htm; - try_files $uri /console/index.html; + # serve static files from root directory + root /usr/share/nginx/html; - # Add cache headers - expires $expires; + # deny IE browsers from going into quirks mode + add_header X-UA-Compatible "IE=Edge"; + # X-Frame-Options is to prevent from clickJacking attack + add_header X-Frame-Options SAMEORIGIN; + # this header enables the Cross-site scripting (XSS) filter + add_header X-XSS-Protection "1; mode=block;"; + # disable content-type sniffing on some browsers. + add_header X-Content-Type-Options nosniff; + + # only cache files in /console/_app/immutable/ + location /console/_app/immutable/ { + try_files $uri =404; + + expires 1y; add_header Pragma public; add_header Cache-Control "public"; + } - # Deny IE browsers from going into quirks mode - add_header X-UA-Compatible "IE=Edge"; - # X-Frame-Options is to prevent from clickJacking attack - add_header X-Frame-Options SAMEORIGIN; - # This header enables the Cross-site scripting (XSS) filter - add_header X-XSS-Protection "1; mode=block;"; - # disable content-type sniffing on some browsers. - add_header X-Content-Type-Options nosniff; + location /console { + index index.html index.html; + try_files $uri /console/index.html; } location / {