feat(frontend): enable gzip compression for static resources in nginx configuration

- Added gzip compression settings to improve loading times for static assets, significantly reducing the size of files served and enhancing performance for users, especially in low bandwidth regions.
This commit is contained in:
wizardchen
2026-05-11 15:43:58 +08:00
committed by lyingbug
parent 0cfbad7f97
commit 9dcb61fb45

View File

@@ -3,7 +3,17 @@ server {
server_name localhost;
# Default 50M, configured via MAX_FILE_SIZE_MB env var
client_max_body_size ${MAX_FILE_SIZE};
# 启用 gzip 压缩静态资源 (前端 index.js 单文件 ~1MB, 不压实测 20s+,
# 压缩后约 200-300KB, 大陆同地域低带宽机器加载从 25s 降到 3-5s)
gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_comp_level 6;
gzip_proxied any;
gzip_types text/plain text/css text/javascript application/javascript application/json
application/xml application/rss+xml image/svg+xml font/ttf font/otf;
# 安全头配置
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;