server {
    listen 80;
    server_name _;

    root /usr/share/nginx/html;
    index index.html;

    # index.html — never cache; ensures clients always get the latest entry point
    # after a deployment (chunks are content-hashed so they can be cached forever)
    location = /index.html {
        add_header Cache-Control "no-cache, no-store, must-revalidate";
        try_files $uri /index.html;
    }

    # SPA fallback for all other routes
    location / {
        try_files $uri $uri/ /index.html;
    }

    # Cache static assets aggressively — content hash in filename guarantees freshness
    location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff2?)$ {
        expires 1y;
        add_header Cache-Control "public, immutable";
    }
}
