server { listen 80; server_name localhost; location ~.*\.(js|css|png|jpg|jpeg|gif)$ { root /www; expires 30d; } location / { root /www; try_files $uri /index.html; # 禁止缓存 HTML,以保证引用最新的 CSS 和 JS 资源 expires -1; } }