Mercurial > hg > nginx-site
view xml/en/docs/http/ngx_http_headers_module.xml @ 1683:5244689583a9
Regenerated.
author | Maxim Konovalov <maxim@nginx.com> |
---|---|
date | Tue, 12 Apr 2016 14:26:10 +0000 |
parents | ab0ebdd7ddac |
children | 4b6d7686e00f |
line wrap: on
line source
<?xml version="1.0"?> <!-- Copyright (C) Igor Sysoev Copyright (C) Nginx, Inc. --> <!DOCTYPE module SYSTEM "../../../../dtd/module.dtd"> <module name="Module ngx_http_headers_module" link="/en/docs/http/ngx_http_headers_module.html" lang="en" rev="7"> <section id="summary"> <para> The <literal>ngx_http_headers_module</literal> module allows adding the <header>Expires</header> and <header>Cache-Control</header> header fields, and arbitrary fields, to a response header. </para> </section> <section id="example" name="Example Configuration"> <para> <example> expires 24h; expires modified +24h; expires @24h; expires 0; expires -1; expires epoch; expires $expires; add_header Cache-Control private; </example> </para> </section> <section id="directives" name="Directives"> <directive name="add_header"> <syntax> <value>name</value> <value>value</value> [<literal>always</literal>]</syntax> <default/> <context>http</context> <context>server</context> <context>location</context> <context>if in location</context> <para> Adds the specified field to a response header provided that the response code equals 200, 201, 204, 206, 301, 302, 303, 304, or 307. A value can contain variables. </para> <para> There could be several <literal>add_header</literal> directives. These directives are inherited from the previous level if and only if there are no <literal>add_header</literal> directives defined on the current level. </para> <para> If the <literal>always</literal> parameter is specified (1.7.5), the header field will be added regardless of the response code. </para> </directive> <directive name="expires"> <syntax>[<literal>modified</literal>] <value>time</value></syntax> <syntax> <literal>epoch</literal> | <literal>max</literal> | <literal>off</literal></syntax> <default>off</default> <context>http</context> <context>server</context> <context>location</context> <context>if in location</context> <para> Enables or disables adding or modifying the <header>Expires</header> and <header>Cache-Control</header> response header fields provided that the response code equals 200, 201, 204, 206, 301, 302, 303, 304, or 307. A parameter can be a positive or negative <link doc="../syntax.xml">time</link>. </para> <para> A time in the <header>Expires</header> field is computed as a sum of the current time and <value>time</value> specified in the directive. If the <literal>modified</literal> parameter is used (0.7.0, 0.6.32) then time is computed as a sum of the file’s modification time and <value>time</value> specified in the directive. </para> <para> In addition, it is possible to specify a time of the day using the “<literal>@</literal>” prefix (0.7.9, 0.6.34): <example> expires @15h30m; </example> </para> <para> The <literal>epoch</literal> parameter corresponds to the absolute time “<literal>Thu, 01 Jan 1970 00:00:01 GMT</literal>”. The contents of the <header>Cache-Control</header> field depends on the sign of the specified time: <list type="bullet"> <listitem> time is negative — <header>Cache-Control: no-cache</header>. </listitem> <listitem> time is positive or zero — <header>Cache-Control: max-age=<value>t</value></header>, where <value>t</value> is a time specified in the directive, in seconds. </listitem> </list> </para> <para> The <literal>max</literal> parameter sets <header>Expires</header> to the value “<literal>Thu, 31 Dec 2037 23:55:55 GMT</literal>”, and <header>Cache-Control</header> to 10 years. </para> <para> The <literal>off</literal> parameter disables adding or modifying the <header>Expires</header> and <header>Cache-Control</header> response header fields. </para> <para> The last parameter value can contain variables (1.7.9): <example> map $sent_http_content_type $expires { default off; application/pdf 42d; ~image/ max; } expires $expires; </example> </para> </directive> </section> </module>