Ngx_http_headers_module

该模块添加‘Expires’ & 'cache-control' 响应头或其他任意响应头;

Example Configuration

expires    24h;
expires    modified +24h;
expires    @24h;
expires    0;
expires    -1;
expires    epoch;
expires    $expires;
add_header Cache-Control private;

Directives

add_header

Syntax: add_header name value [always];
Default:    —
Context:    http, server, location, if in location

#只针对200, 201, 204, 206, 301, 302, 303, 304, 307, or 308,添加response_header,可包含变量;
#含有多个该命令时,本级别没有定义时,可继承上级; 
#‘always’:可忽略状态码添加;

add_trailer

Syntax: add_trailer name value [always];
Default:    —
Context:    http, server, location, if in location
This directive appeared in version 1.13.2.

#只针对200, 201, 204, 206, 301, 302, 303, 304, 307, or 308,添加response_header,可包含变量;
#含有多个该命令时,本级别没有定义时,可继承上级; 
#‘always’:可忽略状态码添加;

expires

Syntax: expires [modified] time;
        expires     epoch | max | off;
Default:    expires off;
Context:    http, server, location, if in location

# 针对200, 201, 204, 206, 301, 302, 303, 304, 307, or 308 状态码是否启用 or 禁用 “加请求头,修改请求头 expires & modified 功能”
# expires = current_time + time;
# 如果 modified 有定义:expires = modified + time;
# @:具体指定cache时间;
# epoch: 格林尼治时间以来绝对时间
# cache-control:
    no-cache & max-age=t & zero
# max: "Thu, 31 Dec 2037 23:55:55 GMT" & Cache-Control:10 years
# off: 禁止启用