From 8478f0c755a38fc7d51b8dfde783ab19e7d32c27 Mon Sep 17 00:00:00 2001 From: Hiram Chirino Date: Fri, 16 Feb 2024 18:18:08 -0500 Subject: [PATCH] frontend: optimize the cache settings so that the assets are aggressively cached. Signed-off-by: Hiram Chirino --- ui/nginx.conf | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/ui/nginx.conf b/ui/nginx.conf index 77d91192b..69c08ad72 100644 --- a/ui/nginx.conf +++ b/ui/nginx.conf @@ -1,9 +1,18 @@ server { - listen 3000; + listen 3000; - location / { - root /usr/share/nginx/html/; - include /etc/nginx/mime.types; - try_files $uri $uri/ /index.html; - } + # all assets contain hash in filename, cache forever + location /assets/ { + root /usr/share/nginx/html/; + include /etc/nginx/mime.types; + try_files $uri $uri/ /index.html; + add_header Cache-Control "public, immutable, max-age=31536000, s-maxage=31536000"; + } + + location / { + root /usr/share/nginx/html/; + include /etc/nginx/mime.types; + try_files $uri $uri/ /index.html; + add_header Cache-Control "public"; + } } \ No newline at end of file