|
The ngx_http_headers_module module allows to emit
the “Expires” and “Cache-Control” header
fields, and to add arbitrary fields to a response header.
Example Configuration
expires 24h;
expires modified +24h;
expires @24h;
expires 0;
expires -1;
expires epoch;
add_header Cache-Control private;
Directives
|
syntax:
|
add_header name value;
|
|
default:
|
—
|
|
context:
|
http, server, location
|
Adds the specified field to a response header provided that
the response code equals 200, 204, 206, 301, 302, 303, 304, or 307.
A value can contain variables.
|
syntax:
|
expires [modified] time;
expires
epoch |
max |
off;
|
|
default:
|
expires off;
|
|
context:
|
http, server, location
|
Enables or disables adding or modifying the “Expires”
and “Cache-Control” response header fields.
A parameter can be a positive or negative
time.
A time in the “Expires” field is computed as a sum of the
current time and time specified in the directive.
If the modified parameter is used (0.7.0, 0.6.32)
then time is computed as a sum of the file’s modification time and
time specified in the directive.
In addition, it is possible to specify a time of the day using
the “@” prefix (0.7.9, 0.6.34):
expires @15h30m;
The epoch parameter corresponds to the absolute time
“Thu, 01 Jan 1970 00:00:01 GMT”.
The contents of the “Cache-Control” field depends
on the sign of the specified time:
-
time is negative — “Cache-Control: no-cache”.
-
time is positive or zero —
“Cache-Control: max-age=
t”,
where t is a time specified in the directive, in seconds.
The max parameter sets “Expires”
to the value “Thu, 31 Dec 2037 23:55:55 GMT”,
and “Cache-Control” to 10 years.
The off parameter disables adding or modifying the
“Expires” and “Cache-Control” response
header fields.
|