diff --git a/conf.d/default.conf b/conf.d/default.conf new file mode 100644 index 0000000..af6f8b0 --- /dev/null +++ b/conf.d/default.conf @@ -0,0 +1,40 @@ +server { + listen 80; + listen [::]:80; + server_name localhost; + root /usr/share/nginx/html; + index index.html; + + # HTML: revalidate so content updates are seen quickly + location ~* \.html?$ { + add_header Cache-Control "public, no-cache"; + try_files $uri $uri/ =404; + } + + # Versioned/hashed assets: long cache, immutable + location ~* \.(js|css)$ { + expires 1y; + add_header Cache-Control "public, immutable"; + try_files $uri =404; + } + + # Images and media + location ~* \.(ico|png|jpg|jpeg|gif|webp|svg|avif)$ { + expires 30d; + add_header Cache-Control "public"; + try_files $uri =404; + } + + # Fonts + location ~* \.(woff2?|ttf|otf|eot)$ { + expires 1y; + add_header Cache-Control "public, immutable"; + try_files $uri =404; + } + + # Default: serve static files, then try directory/index, then 404 + location / { + add_header Cache-Control "public, no-cache"; + try_files $uri $uri/ /index.html =404; + } +}