Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018ks2K99uqCZjAxvy7Rdj1R
47 lines
1.3 KiB
Nginx Configuration File
47 lines
1.3 KiB
Nginx Configuration File
# Immagini, audio e font chiesti con ?v=<versione> (src/version.js) non cambiano mai a quell'indirizzo: cache lunga.
|
|
# Senza ?v= (pagine vecchie) una settimana, come prima.
|
|
map $arg_v $media_cache {
|
|
"" "public, max-age=604800";
|
|
default "public, max-age=31536000, immutable";
|
|
}
|
|
|
|
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|woff2)$ {
|
|
add_header Cache-Control $media_cache;
|
|
}
|
|
location = /index.html {
|
|
add_header Cache-Control "no-cache";
|
|
}
|
|
}
|