forked from kompetenzinventar/ki-frontend
Merge pull request 'Improve SPA cacheing' (!81) from nginx-cacheing into main
Reviewed-on: kompetenzinventar/ki-frontend#81
This commit is contained in:
commit
1b221ab180
@ -9,10 +9,24 @@ server {
|
|||||||
|
|
||||||
#access_log /var/log/nginx/host.access.log main;
|
#access_log /var/log/nginx/host.access.log main;
|
||||||
|
|
||||||
location / {
|
|
||||||
root /usr/share/nginx/html;
|
root /usr/share/nginx/html;
|
||||||
index index.html index.htm;
|
|
||||||
try_files $uri $uri/ /index.html;
|
# routes without dots serve the index.html without caching
|
||||||
|
location / {
|
||||||
|
add_header Cache-Control "no-cache";
|
||||||
|
try_files $uri $uri/index.html /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;
|
||||||
|
Loading…
Reference in New Issue
Block a user