GZip 静态#

允许发送带有“.gz”文件扩展名的预压缩文件,而不是常规文件。

当从源码 构建 时,该模块默认未构建;它应通过 ‑‑with‑http_gzip_static_module 构建选项 启用。

在从 我们的仓库 中的包和镜像中,该模块已包含在构建中。

配置示例#

gzip_static  on;
gzip_proxied expired no-cache no-store private auth;

指令#

gzip_static#

语法

gzip_static on | off | always;

默认值

gzip_static off;

上下文

http, server, location

启用 (on) 或禁用 (off) 检查预压缩文件的存在。以下指令也会被考虑:gzip_http_versiongzip_proxiedgzip_disablegzip_vary

使用 always 时,压缩文件在所有情况下都会被使用,而无需检查客户端是否支持。这在磁盘上没有未压缩文件或者使用了 GunZIP 时很有用。

文件可以通过 gzip 命令或任何其他兼容命令进行压缩。建议原始文件和压缩文件的修改日期和时间相同。