/etc/nginx/nginx.conf
/etc/nginx/conf.d/default.conf
http
或 server
模块中添加配置gzip on
:启用 Gzip 压缩
gzip_min_length 1k
:仅压缩大于 1KB 的文件
gzip_buffers 4 16k
:分配 4 个 16KB 的压缩缓冲区
gzip_comp_level 6
:压缩级别(1-9,6 为平衡性能与压缩率)
gzip_types
:指定压缩的文件类型(如文本、JS、CSS、JSON 等)
gzip_vary on
:告知客户端支持 Gzip 压缩
gzip_proxied any
:对代理请求也启用压缩
gzip_disable
:禁用旧版 IE 的压缩(兼容性)
Content-Encoding: gzip
curl
测试: 扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有