devperf/frontend/nginx.conf
zyc 17696f9049
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m2s
perf: Nginx 开启 gzip 压缩和静态资源缓存,加速首次加载
- gzip 压缩 JS/CSS/JSON 等资源(676KB→226KB)
- /assets/ 静态文件设置 1 年缓存(文件名含 hash)
- index.html 设置 no-cache 确保更新及时

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 11:43:15 +08:00

36 lines
701 B
Nginx Configuration File

server {
listen 80;
root /usr/share/nginx/html;
index index.html;
# Gzip compression
gzip on;
gzip_vary on;
gzip_min_length 256;
gzip_comp_level 6;
gzip_types
text/plain
text/css
text/javascript
application/javascript
application/json
application/xml
image/svg+xml;
# Static assets with hash in filename — long cache
location /assets/ {
expires 1y;
add_header Cache-Control "public, immutable";
}
# SPA fallback
location / {
try_files $uri $uri/ /index.html;
add_header Cache-Control "no-cache";
}
location /api/ {
return 404;
}
}