From fc258d7d27d6d67f3292dcfc0f5365e7d658ae90 Mon Sep 17 00:00:00 2001 From: antoine lebaud Date: Mon, 15 Jul 2024 15:50:28 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7(frontend)=20load=20fresh=20content?= =?UTF-8?q?=20from=20index.html=20on=20every=20request?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prevent caching the index.html file which should load fresh content on every request, based on @manuhabitela suggestion. --- src/frontend/default.conf | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/frontend/default.conf b/src/frontend/default.conf index 0c4fea7f..0ed3ad2f 100644 --- a/src/frontend/default.conf +++ b/src/frontend/default.conf @@ -4,16 +4,22 @@ server { root /usr/share/nginx/html; - # Serve static files + # Serve static files with caching + location ~* \.(css|js|json|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { + expires 30d; + add_header Cache-Control "public, max-age=2592000"; + } + + # Serve other requests without caching location / { try_files $uri $uri/ /index.html; + + # Add no-cache headers + add_header Cache-Control "no-cache, no-store, must-revalidate"; + add_header Pragma "no-cache"; # HTTP 1.0 header for backward compatibility + add_header Expires 0; } # Optionally, handle 404 errors by redirecting to index.html error_page 404 =200 /index.html; - - location ~* \.(css|js|json|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { - expires 30d; - add_header Cache-Control "public, max-age=2592000"; - } }