From 0a9e077f042d208bdf97919f438cec1fdceb0a79 Mon Sep 17 00:00:00 2001 From: antoine lebaud Date: Thu, 11 Jul 2024 20:18:24 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F(frontend)=20add=20caching=20?= =?UTF-8?q?headers=20for=20static=20assets=20in=20Nginx=20config?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Configured Nginx to set caching headers for static assets by adding a location block to match common static file extensions and set an expiration time of 30 days. It should result in faster loading times, reduced bandwidth usage, and a more efficient and responsive user experience. Wdyt @manuhabitela? --- src/frontend/default.conf | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/frontend/default.conf b/src/frontend/default.conf index f503449c..562d0daa 100644 --- a/src/frontend/default.conf +++ b/src/frontend/default.conf @@ -4,6 +4,12 @@ server { root /usr/share/nginx/html; + # Serve static files with caching + location ~* ^/assets/.*\.(css|js|json|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { + expires 30d; + add_header Cache-Control "public, max-age=2592000"; + } + # Serve static files location / { try_files $uri $uri/ /index.html; @@ -15,5 +21,4 @@ server { # Optionally, handle 404 errors by redirecting to index.html error_page 404 =200 /index.html; - }