Improve SPA cacheing

This commit is contained in:
Brain 2023-11-06 18:35:05 +01:00
parent e7ff487aeb
commit 26edf1d4b2
Signed by untrusted user: Brain
GPG Key ID: EE936E31EE3AEE7A

View File

@ -9,10 +9,24 @@ server {
#access_log /var/log/nginx/host.access.log main; #access_log /var/log/nginx/host.access.log main;
root /usr/share/nginx/html;
# routes without dots serve the index.html without caching
location / { location / {
root /usr/share/nginx/html; add_header Cache-Control "no-cache";
index index.html index.htm; try_files $uri $uri/index.html /index.html;
try_files $uri $uri/ /index.html; }
# static js and css files that get replaced instead of updated
location ~ \.(js|css) {
add_header Cache-Control "public, max-age=31536000, immutable";
try_files $uri =404;
}
# cache other static files for 30 days
location ~ \.(?!html) {
add_header Cache-Control "public, max-age=2592000";
try_files $uri =404;
} }
#error_page 404 /404.html; #error_page 404 /404.html;