概述Brotli(br)与 Zstandard(zstd)提供更高效的压缩,浏览器通过 Accept-Encoding 与服务器协商,返回对应 Content-Encoding。需正确设置压缩级别、变体缓存与 MIME。示例:响应头与配置Accept-Encoding: br, gzip, deflate, zstd
Content-Encoding: br
gzip off;
brotli on;
brotli_types text/html text/css application/javascript application/json;
工程建议选择与回退:优先 br;在边缘/代理支持时考虑 zstd;保持 gzip 作为广泛回退。变体与缓存:基于 Accept-Encoding 维度管理缓存;避免混淆不同编码。压缩级别:平衡压缩率与 CPU;对静态资源使用预压缩文件。参考与验证RFC 7932 Brotli 数据格式:https://www.rfc-editor.org/rfc/rfc7932RFC 8478 Zstandard 与 zstd Content-Encoding:https://www.rfc-editor.org/rfc/rfc8478MDN Content-Encoding 文档:https://developer.mozilla.org/docs/Web/HTTP/Headers/Content-Encoding

发表评论 取消回复