WARNING: this article is obsoleted. Please refer to http://nginx.org/en/docs/ for the latest official documentation.
This module allows setting arbitrary HTTP headers.
|Syntax:||add_header name value|
if in location
Adds headers to the HTTP response when the response code is equal to 200, 204, 301, 302 or 304.
Note that for headers other than
Last-Modified, 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 [ |
if in location
Controls whether the response should be marked with an expiry time, and if so, what time that is.
offprevents changes to the
Expiresheader to 1 January, 1970 00:00:01 GMT.
Expiresheader to 31 December 2037 23:59:59 GMT, and the
Cache-Controlmax-age to 10 years.
- A time without an
@prefix specifies an expiry time relative to either the response time (if the time is not preceded with "modified") or the file's modification time (when "modified" is present — available from versions 0.7.0 & 0.6.32). A negative time can be specified, which sets the
- Times written with an
@prefix represent an absolute time-of-day expiry, written in either the form Hh or Hh:Mm, where H ranges from 0 to 24, and M ranges from 0 to 59 (available from versions 0.7.9 & 0.6.34).
A non-negative time or time-of-day sets the
Cache-Control header to
max-age = #, where # is the appropriate time in seconds.
expires works only for 200, 204, 301, 302, and 304 responses.
- The third-party headers_more module for adding, replacing, and clearing both input and output headers.