diff --git a/reverse-proxy/nginx.conf.template b/reverse-proxy/nginx.conf.template index e78f843..87e3ebd 100644 --- a/reverse-proxy/nginx.conf.template +++ b/reverse-proxy/nginx.conf.template @@ -1,3 +1,8 @@ +map $uri $static_file { + ~*\.(?:css|js|mjs|png|jpg|jpeg|gif|svg|ico|webp|woff2?)$ 1; + default 0; +} + server { listen 80 default_server; server_name ${SERVER_NAME}; @@ -38,12 +43,13 @@ server { location / { proxy_pass http://web:80/; + try_files $uri =404; + + if ($static_file) { + add_header Cache-Control "public, max-age=31536000, immutable" always; + } + add_header Cache-Control "no-store, no-cache" always; } - location ~* \.(?:css|js|mjs|png|jpg|jpeg|gif|svg|ico|webp|woff2?)$ { - proxy_pass http://web:80/; - add_header Cache-Control "public, max-age=31536000, immutable" always; - } - }