NginxHttpHeadersModule
Contents |
Synopsis
This module allows setting arbitrary HTTP headers.
Examples
expires 24h; expires 0; expires -1; expires epoch; add_header Cache-Control private;
Directives
add_header
syntax: add_header name value
default: none
context: http, server, location
Directive adds headers to the HTTP response when the response code is equal to 200, 204, 301, 302 or 304.
In the value it is possible to use variables.
Note that it just appends a new header entry to the output header list. So you can't use this directive to rewrite existing headers like Server. Use the headers_more module for it.
expires
syntax: expires [time|epoch|max|off]
default: expires off
context: http, server, location
It allows or prevents adding or changing the Expires and Cache-Control in the response headers.
It is possible to assign positive or negative times. Time in the Expires header is obtained as the sum of the current time and the time assigned in the directive.
epoch indicates the absolute time of 1 January, 1970, 00:00:01 GMT.
max assigns the time of 31 December 2037 23:59:59 GMT to the Expires header and 10 years for the Cache-Control header.
Contents of the Cache-Control header depends on the sign of the preset time:
- negative time:
Cache-Control: no-cache - positive time or equal to zero:
Cache-Control: max-age = #, where#is the time in seconds, assigned in the directive.
The parameter "off" prevents changes to "Expires" and "Cache-Control" in the headers.
Note: expires works only for 200, 204, 301, 302, and 304 responses.
References
See Also
- The third-party headers_more module for adding, replacing, and clearing both input and output headers.












