server { listen 80; server_name _; root /usr/share/nginx/html; index index.html; # Compressione per i moduli JS e i fogli di stile. gzip on; gzip_types text/css application/javascript application/json image/svg+xml; # I moduli ES richiedono il MIME type corretto. types { text/html html; text/css css; application/javascript js mjs; application/json json map; image/png png; image/webp webp; audio/mpeg mp3; image/svg+xml svg; image/x-icon ico; font/woff2 woff2; } location / { try_files $uri $uri/ =404; } # Gli script e i fogli di stile non hanno hash nel nome: rivalidali a ogni avvio. location ~* \.(css|js|mjs|json)$ { add_header Cache-Control "no-cache"; } location ~* \.(png|webp|mp3)$ { expires 7d; add_header Cache-Control "public"; } location = /index.html { add_header Cache-Control "no-cache"; } }