24886123d260485c4d9a0194d2cbb6192e642df9slive<!DOCTYPE modulesynopsis SYSTEM "/style/modulesynopsis.dtd">
e942c741056732f50da2074b36fe59805d370650slive<?xml-stylesheet type="text/xsl" href="/style/manual.en.xsl"?>
5f5d1b4cc970b7f06ff8ef6526128e9a27303d88nd<!-- $LastChangedRevision$ -->
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding Licensed to the Apache Software Foundation (ASF) under one or more
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding contributor license agreements. See the NOTICE file distributed with
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding this work for additional information regarding copyright ownership.
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding The ASF licenses this file to You under the Apache License, Version 2.0
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding (the "License"); you may not use this file except in compliance with
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding the License. You may obtain a copy of the License at
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd Unless required by applicable law or agreed to in writing, software
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd distributed under the License is distributed on an "AS IS" BASIS,
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd See the License for the specific language governing permissions and
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd limitations under the License.
7f3fdc63be07f2ad39e01a44e68e9324998a5c03slive<code>Cache-Control</code> HTTP headers according to user-specified
7f3fdc63be07f2ad39e01a44e68e9324998a5c03slivecriteria</description>
24886123d260485c4d9a0194d2cbb6192e642df9slive <p>This module controls the setting of the <code>Expires</code>
7f3fdc63be07f2ad39e01a44e68e9324998a5c03slive HTTP header and the <code>max-age</code> directive of the
7f3fdc63be07f2ad39e01a44e68e9324998a5c03slive <code>Cache-Control</code> HTTP header in server responses. The
7f3fdc63be07f2ad39e01a44e68e9324998a5c03slive expiration date can set to be relative to either the time the
7f3fdc63be07f2ad39e01a44e68e9324998a5c03slive source file was last modified, or to the time of the client
7f3fdc63be07f2ad39e01a44e68e9324998a5c03slive access.</p>
7f3fdc63be07f2ad39e01a44e68e9324998a5c03slive <p>These HTTP headers are an instruction to the client about the
7f3fdc63be07f2ad39e01a44e68e9324998a5c03slive document's validity and persistence. If cached, the document may
7f3fdc63be07f2ad39e01a44e68e9324998a5c03slive be fetched from the cache rather than from the source until this
7f3fdc63be07f2ad39e01a44e68e9324998a5c03slive time has passed. After that, the cache copy is considered
7f3fdc63be07f2ad39e01a44e68e9324998a5c03slive "expired" and invalid, and a new copy must be obtained from the
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim source.</p>
7f3fdc63be07f2ad39e01a44e68e9324998a5c03slive <p>To modify <code>Cache-Control</code> directives other than
7f3fdc63be07f2ad39e01a44e68e9324998a5c03slive href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9">RFC
7f3fdc63be07f2ad39e01a44e68e9324998a5c03slive module="mod_headers">Header</directive> directive.</p>
1422a46130adacd1ee80183aaddffc8e65f64996covener <p> When the <code>Expires</code> header is already part of the response
860b4efe27e7c1c9a2bf5c872b29c90f76849b51jim generated by the server, for example when generated by a CGI script or
1422a46130adacd1ee80183aaddffc8e65f64996covener proxied from an origin server, this module does not change or add
8c150dd80c97896ccf1db42d19b8efca2602232bcovener an <code>Expires</code> or <code>Cache-Control</code> header.</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>
69cdc59729e1a733aafee3ef613eadfb8e437c11humbedoohExpiresDefault "<var>base</var> [plus <var>num</var> <var>type</var>] [<var>num</var> <var>type</var>] ..."
69cdc59729e1a733aafee3ef613eadfb8e437c11humbedoohExpiresByType type/encoding "<var>base</var> [plus <var>num</var> <var>type</var>] [<var>num</var> <var>type</var>] ..."
69cdc59729e1a733aafee3ef613eadfb8e437c11humbedooh </highlight>
5a5c9555f68ed95ae9cde56baf2a27c727eb6242rbowen <p>The <code>plus</code> keyword is optional. <var>num</var>
24886123d260485c4d9a0194d2cbb6192e642df9slive should be an integer value [acceptable to <code>atoi()</code>],
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>
69cdc59729e1a733aafee3ef613eadfb8e437c11humbedoohExpiresDefault "access plus 1 month"
69cdc59729e1a733aafee3ef613eadfb8e437c11humbedoohExpiresDefault "access plus 4 weeks"
69cdc59729e1a733aafee3ef613eadfb8e437c11humbedoohExpiresDefault "access plus 30 days"
69cdc59729e1a733aafee3ef613eadfb8e437c11humbedooh </highlight>
24886123d260485c4d9a0194d2cbb6192e642df9slive <p>The expiry time can be fine-tuned by adding several
69cdc59729e1a733aafee3ef613eadfb8e437c11humbedoohExpiresByType text/html "access plus 1 month 15 days 2 hours"
69cdc59729e1a733aafee3ef613eadfb8e437c11humbedoohExpiresByType image/gif "modification plus 5 hours 3 minutes"
69cdc59729e1a733aafee3ef613eadfb8e437c11humbedooh </highlight>
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
7f3fdc63be07f2ad39e01a44e68e9324998a5c03slive <code>Expires</code> and <code>Cache-Control</code> headers for
7f3fdc63be07f2ad39e01a44e68e9324998a5c03slive the document realm in question. (That is, if found in an
7f3fdc63be07f2ad39e01a44e68e9324998a5c03slive <code>.htaccess</code> file, for instance, it applies only to
7f3fdc63be07f2ad39e01a44e68e9324998a5c03slive documents generated from that directory.) If set to
7f3fdc63be07f2ad39e01a44e68e9324998a5c03slive <code>Off</code>, the headers will not be generated for any
7f3fdc63be07f2ad39e01a44e68e9324998a5c03slive document in the realm (unless overridden at a lower level, such as
7f3fdc63be07f2ad39e01a44e68e9324998a5c03slive an <code>.htaccess</code> file overriding a server config
7f3fdc63be07f2ad39e01a44e68e9324998a5c03slive file). If set to <code>On</code>, the headers will be added to
7f3fdc63be07f2ad39e01a44e68e9324998a5c03slive served documents according to the criteria defined by the
7f3fdc63be07f2ad39e01a44e68e9324998a5c03slive <directive module="mod_expires">ExpiresByType</directive> and
7f3fdc63be07f2ad39e01a44e68e9324998a5c03slive <directive module="mod_expires">ExpiresDefault</directive>
24886123d260485c4d9a0194d2cbb6192e642df9slive <p>Note that this directive does not guarantee that an
7f3fdc63be07f2ad39e01a44e68e9324998a5c03slive <code>Expires</code> or <code>Cache-Control</code> header will be
7f3fdc63be07f2ad39e01a44e68e9324998a5c03slive generated. If the criteria aren't met, no header will be sent, and
7f3fdc63be07f2ad39e01a44e68e9324998a5c03slive the effect will be as though this directive wasn't even
7f3fdc63be07f2ad39e01a44e68e9324998a5c03slive 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>
7f3fdc63be07f2ad39e01a44e68e9324998a5c03slive <code>Cache-Control</code> header generated for documents of the
7f3fdc63be07f2ad39e01a44e68e9324998a5c03slive specified type (<em>e.g.</em>, <code>text/html</code>). The second
7f3fdc63be07f2ad39e01a44e68e9324998a5c03slive argument sets the number of seconds that will be added to a base
7f3fdc63be07f2ad39e01a44e68e9324998a5c03slive time to construct the expiration date. The <code>Cache-Control:
7f3fdc63be07f2ad39e01a44e68e9324998a5c03slive max-age</code> is calculated by subtracting the request time from
7f3fdc63be07f2ad39e01a44e68e9324998a5c03slive the expiration date and expressing the result in seconds.</p>
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>
69cdc59729e1a733aafee3ef613eadfb8e437c11humbedooh# enable expirations
69cdc59729e1a733aafee3ef613eadfb8e437c11humbedoohExpiresActive On
69cdc59729e1a733aafee3ef613eadfb8e437c11humbedooh# expire GIF images after a month in the client's cache
69cdc59729e1a733aafee3ef613eadfb8e437c11humbedooh# HTML documents are good for a week from the
69cdc59729e1a733aafee3ef613eadfb8e437c11humbedooh# time they were changed
69cdc59729e1a733aafee3ef613eadfb8e437c11humbedooh </highlight>
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>