server { listen 80; server_name _; root /usr/share/nginx/html; index index.html; # Gzip compression gzip on; gzip_static on; # serve .gz files if available gzip_types text/plain text/css application/json application/javascript text/javascript application/x-javascript application/xml font/woff2 image/svg+xml; gzip_proxied any; gzip_vary on; gzip_min_length 256; # Cache aggressively for hashed assets (JS, CSS, fonts, images, etc.) location ~* \.(?:js|css|woff2?|eot|ttf|otf|svg|ico|jpg|jpeg|png|gif|webp)$ { expires 1y; access_log off; add_header Cache-Control "public, immutable"; try_files $uri =404; } # Cache /assets/ folder (if you store fonts/images here) location ^~ /assets/ { expires 1y; access_log off; add_header Cache-Control "public, immutable"; try_files $uri =404; } location / { try_files $uri /index.html; } location /static/ { expires 1y; add_header Cache-Control "public, immutable"; } error_page 404 /index.html; }