server { listen 80; server_name _; root /usr/share/nginx/html; index index.html; gzip on; gzip_min_length 1k; gzip_comp_level 5; gzip_types text/plain text/css application/javascript application/json image/svg+xml; # hash 路由,所有非静态资源请求回落到 index.html location / { try_files $uri $uri/ /index.html; } location ~* \.(js|css|png|jpe?g|gif|svg|woff2?|ttf|eot)$ { expires 7d; add_header Cache-Control "public, max-age=604800"; } location = /index.html { add_header Cache-Control "no-cache, no-store, must-revalidate"; } }