mod_expires.xml revision eaaf220dae7a60b63d5487d9e3b1644f4a1dbf23
24886123d260485c4d9a0194d2cbb6192e642df9slive<!DOCTYPE modulesynopsis SYSTEM "/style/modulesynopsis.dtd">
e942c741056732f50da2074b36fe59805d370650slive<?xml-stylesheet type="text/xsl" href="/style/manual.en.xsl"?>
24886123d260485c4d9a0194d2cbb6192e642df9slive<modulesynopsis>
eaaf220dae7a60b63d5487d9e3b1644f4a1dbf23nd<description>Generation of <code>Expires</code> HTTP headers according to
eaaf220dae7a60b63d5487d9e3b1644f4a1dbf23nduser-specified criteria</description>
24886123d260485c4d9a0194d2cbb6192e642df9slive <p>This module controls the setting of the <code>Expires</code>
24886123d260485c4d9a0194d2cbb6192e642df9slive HTTP header in server responses. The expiration date can set to
24886123d260485c4d9a0194d2cbb6192e642df9slive be relative to either the time the source file was last
24886123d260485c4d9a0194d2cbb6192e642df9slive modified, or to the time of the client access.</p>
24886123d260485c4d9a0194d2cbb6192e642df9slive <p>The <code>Expires</code> HTTP header is an instruction to
24886123d260485c4d9a0194d2cbb6192e642df9slive the client about the document's validity and persistence. If
24886123d260485c4d9a0194d2cbb6192e642df9slive cached, the document may be fetched from the cache rather than
24886123d260485c4d9a0194d2cbb6192e642df9slive from the source until this time has passed. After that, the
24886123d260485c4d9a0194d2cbb6192e642df9slive cache copy is considered "expired" and invalid, and a new copy
24886123d260485c4d9a0194d2cbb6192e642df9slive must be obtained from the source.</p>
eaaf220dae7a60b63d5487d9e3b1644f4a1dbf23nd<section id="AltSyn"><title>Alternate Interval Syntax</title>
eaaf220dae7a60b63d5487d9e3b1644f4a1dbf23nd <p>The <directive module="mod_expires">ExpiresDefault</directive> and
24886123d260485c4d9a0194d2cbb6192e642df9slive <directive module="mod_expires">ExpiresByType</directive> directives
24886123d260485c4d9a0194d2cbb6192e642df9slive can also be defined in a more readable syntax of the form:</p>
eaaf220dae7a60b63d5487d9e3b1644f4a1dbf23nd ExpiresDefault "<base> [plus] {<num>
24886123d260485c4d9a0194d2cbb6192e642df9slive <type>}*"<br />
24886123d260485c4d9a0194d2cbb6192e642df9slive {<num> <type>}*"
eaaf220dae7a60b63d5487d9e3b1644f4a1dbf23nd </example>
eaaf220dae7a60b63d5487d9e3b1644f4a1dbf23nd <p>The <code>plus</code> keyword is optional. <num>
24886123d260485c4d9a0194d2cbb6192e642df9slive should be an integer value [acceptable to <code>atoi()</code>],
24886123d260485c4d9a0194d2cbb6192e642df9slive and <type> is one of:</p>
24886123d260485c4d9a0194d2cbb6192e642df9slive <p>For example, any of the following directives can be used to
24886123d260485c4d9a0194d2cbb6192e642df9slive make documents expire 1 month after being accessed, by
24886123d260485c4d9a0194d2cbb6192e642df9slive default:</p>
eaaf220dae7a60b63d5487d9e3b1644f4a1dbf23nd ExpiresDefault "access plus 1 month"<br />
eaaf220dae7a60b63d5487d9e3b1644f4a1dbf23nd ExpiresDefault "access plus 4 weeks"<br />
eaaf220dae7a60b63d5487d9e3b1644f4a1dbf23nd ExpiresDefault "access plus 30 days"
eaaf220dae7a60b63d5487d9e3b1644f4a1dbf23nd </example>
24886123d260485c4d9a0194d2cbb6192e642df9slive <p>The expiry time can be fine-tuned by adding several
24886123d260485c4d9a0194d2cbb6192e642df9slive '<num> <type>' clauses:</p>
24886123d260485c4d9a0194d2cbb6192e642df9slive days 2 hours"<br />
eaaf220dae7a60b63d5487d9e3b1644f4a1dbf23nd </example>
24886123d260485c4d9a0194d2cbb6192e642df9slive <p>Note that if you use a modification date based setting, the
24886123d260485c4d9a0194d2cbb6192e642df9slive Expires header will <strong>not</strong> be added to content
24886123d260485c4d9a0194d2cbb6192e642df9slive that does not come from a file on disk. This is due to the fact
24886123d260485c4d9a0194d2cbb6192e642df9slive that there is no modification time for such content.</p>
24886123d260485c4d9a0194d2cbb6192e642df9slive<directivesynopsis>
eaaf220dae7a60b63d5487d9e3b1644f4a1dbf23ndheaders</description>
24886123d260485c4d9a0194d2cbb6192e642df9slive<context>virtual host</context><context>directory</context>
24886123d260485c4d9a0194d2cbb6192e642df9slive <p>This directive enables or disables the generation of the
24886123d260485c4d9a0194d2cbb6192e642df9slive <code>Expires</code> header for the document realm in question.
24886123d260485c4d9a0194d2cbb6192e642df9slive (That is, if found in an <code>.htaccess</code> file, for
24886123d260485c4d9a0194d2cbb6192e642df9slive instance, it applies only to documents generated from that
eaaf220dae7a60b63d5487d9e3b1644f4a1dbf23nd directory.) If set to <code>Off</code>, no <code>Expires</code> header
eaaf220dae7a60b63d5487d9e3b1644f4a1dbf23nd will be generated for any document in the realm (unless overridden at
eaaf220dae7a60b63d5487d9e3b1644f4a1dbf23nd a lower level, such as an <code>.htaccess</code> file overriding a
eaaf220dae7a60b63d5487d9e3b1644f4a1dbf23nd server config file). If set to <code>On</code>, the header will be
eaaf220dae7a60b63d5487d9e3b1644f4a1dbf23nd added to served documents according to the criteria defined by the
24886123d260485c4d9a0194d2cbb6192e642df9slive <directive module="mod_expires">ExpiresByType</directive> and
24886123d260485c4d9a0194d2cbb6192e642df9slive <directive module="mod_expires">ExpiresDefault</directive> directives
24886123d260485c4d9a0194d2cbb6192e642df9slive <p>Note that this directive does not guarantee that an
24886123d260485c4d9a0194d2cbb6192e642df9slive <code>Expires</code> header will be generated. If the criteria
24886123d260485c4d9a0194d2cbb6192e642df9slive aren't met, no header will be sent, and the effect will be as
24886123d260485c4d9a0194d2cbb6192e642df9slive though this directive wasn't even specified.</p>
24886123d260485c4d9a0194d2cbb6192e642df9slive</directivesynopsis>
24886123d260485c4d9a0194d2cbb6192e642df9slive<directivesynopsis>
24886123d260485c4d9a0194d2cbb6192e642df9slive<description>Value of the <code>Expires</code> header configured
24886123d260485c4d9a0194d2cbb6192e642df9sliveby MIME type</description>
eaaf220dae7a60b63d5487d9e3b1644f4a1dbf23nd<contextlist><context>server config</context><context>virtual host</context>
eaaf220dae7a60b63d5487d9e3b1644f4a1dbf23nd<context>directory</context><context>.htaccess</context></contextlist>
24886123d260485c4d9a0194d2cbb6192e642df9slive <p>This directive defines the value of the <code>Expires</code>
eaaf220dae7a60b63d5487d9e3b1644f4a1dbf23nd header generated for documents of the specified type (<em>e.g.</em>,
eaaf220dae7a60b63d5487d9e3b1644f4a1dbf23nd <code>text/html</code>). The second argument sets the number of
eaaf220dae7a60b63d5487d9e3b1644f4a1dbf23nd seconds that will be added to a base time to construct the expiration
24886123d260485c4d9a0194d2cbb6192e642df9slive <p>The base time is either the last modification time of the
24886123d260485c4d9a0194d2cbb6192e642df9slive file, or the time of the client's access to the document. Which
24886123d260485c4d9a0194d2cbb6192e642df9slive should be used is specified by the
eaaf220dae7a60b63d5487d9e3b1644f4a1dbf23nd <code><var><code></var></code> field; <code>M</code>
24886123d260485c4d9a0194d2cbb6192e642df9slive means that the file's last modification time should be used as
eaaf220dae7a60b63d5487d9e3b1644f4a1dbf23nd the base time, and <code>A</code> means the client's access
24886123d260485c4d9a0194d2cbb6192e642df9slive time should be used.</p>
eaaf220dae7a60b63d5487d9e3b1644f4a1dbf23nd <p>The difference in effect is subtle. If <code>M</code> is used,
24886123d260485c4d9a0194d2cbb6192e642df9slive all current copies of the document in all caches will expire at
24886123d260485c4d9a0194d2cbb6192e642df9slive the same time, which can be good for something like a weekly
eaaf220dae7a60b63d5487d9e3b1644f4a1dbf23nd notice that's always found at the same URL. If <code>A</code> is
24886123d260485c4d9a0194d2cbb6192e642df9slive used, the date of expiration is different for each client; this
24886123d260485c4d9a0194d2cbb6192e642df9slive can be good for image files that don't change very often,
24886123d260485c4d9a0194d2cbb6192e642df9slive particularly for a set of related documents that all refer to
24886123d260485c4d9a0194d2cbb6192e642df9slive the same images (<em>i.e.</em>, the images will be accessed
24886123d260485c4d9a0194d2cbb6192e642df9slive repeatedly within a relatively short timespan).</p>
eaaf220dae7a60b63d5487d9e3b1644f4a1dbf23nd # enable expirations<br />
eaaf220dae7a60b63d5487d9e3b1644f4a1dbf23nd ExpiresActive On<br />
eaaf220dae7a60b63d5487d9e3b1644f4a1dbf23nd # expire GIF images after a month in the client's cache<br />
eaaf220dae7a60b63d5487d9e3b1644f4a1dbf23nd # HTML documents are good for a week from the<br />
eaaf220dae7a60b63d5487d9e3b1644f4a1dbf23nd # time they were changed<br />
eaaf220dae7a60b63d5487d9e3b1644f4a1dbf23nd </example>
24886123d260485c4d9a0194d2cbb6192e642df9slive <p>Note that this directive only has effect if
24886123d260485c4d9a0194d2cbb6192e642df9slive <code>ExpiresActive On</code> has been specified. It overrides,
24886123d260485c4d9a0194d2cbb6192e642df9slive for the specified MIME type <em>only</em>, any expiration date
24886123d260485c4d9a0194d2cbb6192e642df9slive set by the <directive module="mod_expires">ExpiresDefault</directive>
24886123d260485c4d9a0194d2cbb6192e642df9slive directive.</p>
24886123d260485c4d9a0194d2cbb6192e642df9slive <p>You can also specify the expiration time calculation using
24886123d260485c4d9a0194d2cbb6192e642df9slive an <a href="#AltSyn">alternate syntax</a>, described earlier in
24886123d260485c4d9a0194d2cbb6192e642df9slive this document.</p>
24886123d260485c4d9a0194d2cbb6192e642df9slive</directivesynopsis>
24886123d260485c4d9a0194d2cbb6192e642df9slive<directivesynopsis>
24886123d260485c4d9a0194d2cbb6192e642df9slive<description>Default algorithm for calculating expiration time</description>
eaaf220dae7a60b63d5487d9e3b1644f4a1dbf23nd<syntax>ExpiresDefault <var><code>seconds</var></syntax>
eaaf220dae7a60b63d5487d9e3b1644f4a1dbf23nd<contextlist><context>server config</context><context>virtual host</context>
eaaf220dae7a60b63d5487d9e3b1644f4a1dbf23nd<context>directory</context><context>.htaccess</context></contextlist>
24886123d260485c4d9a0194d2cbb6192e642df9slive <p>This directive sets the default algorithm for calculating the
24886123d260485c4d9a0194d2cbb6192e642df9slive expiration time for all documents in the affected realm. It can be
24886123d260485c4d9a0194d2cbb6192e642df9slive overridden on a type-by-type basis by the <directive
24886123d260485c4d9a0194d2cbb6192e642df9slive module="mod_expires">ExpiresByType</directive> directive. See the
24886123d260485c4d9a0194d2cbb6192e642df9slive description of that directive for details about the syntax of the
24886123d260485c4d9a0194d2cbb6192e642df9slive argument, and the <a href="#AltSyn">alternate syntax</a>
24886123d260485c4d9a0194d2cbb6192e642df9slive description as well.</p>
24886123d260485c4d9a0194d2cbb6192e642df9slive</directivesynopsis>
24886123d260485c4d9a0194d2cbb6192e642df9slive</modulesynopsis>