Nginx ngx_http_gzip_static_module模块基本指令整理

原创文章,转载请指明出处并保留原文url地址

本文主要针对nginx的ngx_http_gzip_static_module模块做简单介绍,本文具体包括如下指令:gzip_static

这个ngx_http_gzip_static_module模块允许发送具有".gz"扩展名的预编译文件给客户端。

这个模块不是默认的内建模块, 需要采用--with-http_gzip_static_module配置指令进行配置来开启相关功能。

配置例子如下:

Example Configuration

gzip_static  on;

gzip_proxied expired no-cache no-store private auth;

Nginx原文:

The ngx_http_gzip_static_module module allows to send precompressed files with the “.gz” filename extension instead of regular files.

This module is not built by default, it should be enabled with the --with-http_gzip_static_module configuration parameter.

Example Configuration

gzip_static  on;

gzip_proxied expired no-cache no-store private auth;

1. gzip_static

syntax:gzip_static         on | off | always;
default:gzip_static off;
context:http, server, location

“on”和“off”打开或者关闭预编译文件存在的检查的功能, 下面的指令也将被参考:

gzip_http_version, gzip_proxied, gzip_disable和gzip_vary。

当配置取值为“always”时,gzip文件形式在这种情况下都适用,不用检查是否客户端支持压缩功能。这个选项适合在磁盘上没有解压缩文件或者使用ngx_http_gunzip_module模块情况。

文件可以采用gzip命令进行压缩或者采用其他兼容命令进行。建议修改压缩文件的时间日期同原始文件的时间日期相同

Nginx原文:

Enables (“on”) or disables (“off”) checking the existence of precompressed files. The following directives are also taken into account: gzip_http_version, gzip_proxied, gzip_disable, and gzip_vary.

With the “always” value (1.3.6), gzipped file is used in all cases, without checking if the client supports it. It is useful if there are no uncompressed files on the disk anyway or the ngx_http_gunzip_module is used.

The files can be compressed using the gzip command, or any other compatible. It is recommended that the modification date and time of original and compressed files be the same.

发表评论