132N/A<!
DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
132N/A <
TITLE>Apache module mod_expires</
TITLE>
132N/A<!-- Background white, links blue (unvisited), navy (visited), red (active) --> 132N/A <
H1 ALIGN="CENTER">Module mod_expires</
H1>
132N/A is <
STRONG>not</
STRONG> compiled in by default. It provides for the
132N/A generation of <
CODE>Expires</
CODE> headers according to user-specified
132N/A This module controls the setting of the <
CODE>Expires</
CODE> HTTP
215N/A header in server responses. The expiration date can set to be
132N/A relative to either the time the source file was last modified, or to
132N/A the time of the client access.
132N/A The <
CODE>Expires</
CODE> HTTP header is an instruction to the client
132N/A about the document's validity and persistence. If cached, the document
132N/A may be fetched from the cache rather than from the source until this
132N/A time has passed. After that, the cache copy is considered
132N/A "expired" and invalid, and a new copy must be obtained from
132N/A <
H2><
A NAME="expiresactive">
132N/A ExpiresActive directive
132N/A <!--%plaintext <?INDEX {\tt ExpiresActive} directive> --> 132N/A ><
STRONG>Syntax:</
STRONG></
A> ExpiresActive <
EM>boolean</
EM>
132N/A ><
STRONG>Context:</
STRONG></
A> server config, virtual host, directory,
132N/A ><
STRONG>Override:</
STRONG></
A> Indexes
132N/A ><
STRONG>Status:</
STRONG></
A> Extension
132N/A ><
STRONG>Module:</
STRONG></
A> mod_expires
132N/A This directive enables or disables the generation of the
132N/A <
CODE>Expires</
CODE> header for the document realm in question. (That
132N/A is, if found in an <
CODE>.htaccess</
CODE> file, for instance, it
132N/A applies only to documents generated from that directory.) If set to
219N/A <
EM><
CODE>Off</
CODE></
EM>, no <
CODE>Expires</
CODE> header will be
979N/A generated for any document in the realm (unless overridden at a lower
220N/A level, such as an <
CODE>.htaccess</
CODE> file overriding a server
341N/A config file). If set to <
EM><
CODE>On</
CODE></
EM>, the header will be
341N/A added to served documents according to the criteria defined by the
736N/A Note that this directive does not guarantee that an
487N/A <
CODE>Expires</
CODE> header will be generated. If the criteria aren't
704N/A met, no header will be sent, and the effect will be as though this
487N/A directive wasn't even specified.
487N/A <
H2><
A NAME="expiresbytype">
487N/A ExpiresByType directive
320N/A <!--%plaintext <?INDEX {\tt ExpiresByType} directive> --> 949N/A ><
STRONG>Syntax:</
STRONG></
A> ExpiresByType <
EM>mime-type
336N/A <code>seconds</
EM>
336N/A ><
STRONG>Context:</
STRONG></
A> server config, virtual host, directory,
379N/A ><
STRONG>Override:</
STRONG></
A> Indexes
411N/A ><
STRONG>Status:</
STRONG></
A> Extension
320N/A ><
STRONG>Module:</
STRONG></
A> mod_expires
949N/A This directive defines the value of the <
CODE>Expires</
CODE> header
132N/A generated for documents of the specified type (<
EM>
e.g.</
EM>,
949N/A <
CODE>
text/
html</
CODE>). The second argument sets the number of
949N/A seconds that will be added to a base time to construct the expiration
949N/A The base time is either the last modification time of the file, or the
949N/A time of the client's access to the document. Which should be used is
949N/A specified by the <
CODE><
EM><code></
EM></
CODE> field;
949N/A <
STRONG>M</
STRONG> means that the file's last modification time should
949N/A be used as the base time, and <
STRONG>A</
STRONG> means the client's
949N/A access time should be used.
949N/A The difference in effect is subtle. If <
EM>M</
EM> is used, all current
949N/A copies of the document in all caches will expire at the same time,
949N/A which can be good for something like a weekly notice that's always
949N/A found at the same URL. If <
EM>A</
EM> is used, the date of expiration
949N/A is different for each client; this can be good for image files that
949N/A don't change very often, particularly for a set of related documents
949N/A that all refer to the same images (<
EM>
i.e.</
EM>, the images will be
949N/A accessed repeatedly within a relatively short timespan).
949N/A <
STRONG>Example:</
STRONG>
230N/A ExpiresActive On # enable expirations
230N/A ExpiresByType
image/
gif A2592000 # expire GIF images after a month
230N/A # in the client's cache
230N/A ExpiresByType
text/
html M604800 # HTML documents are good for a
230N/A # week from the time they were
230N/A Note that this directive only has effect if <
CODE>ExpiresActive
230N/A On</
CODE> has been specified. It overrides, for the specified MIME
230N/A type <
EM>only</
EM>, any expiration date set by the
230N/A You can also specify the expiration time calculation using an
949N/A described later in this document.
741N/A <
H2><
A NAME="expiresdefault">
132N/A ExpiresDefault directive
211N/A <!--%plaintext <?INDEX {\tt ExpiresDefault} directive> --> 213N/A ><
STRONG>Syntax:</
STRONG></
A> ExpiresDefault <
EM><code>seconds</
EM>
213N/A ><
STRONG>Context:</
STRONG></
A> server config, virtual host, directory,
213N/A ><
STRONG>Override:</
STRONG></
A> Indexes
213N/A ><
STRONG>Status:</
STRONG></
A> Extension
213N/A ><
STRONG>Module:</
STRONG></
A> mod_expires
845N/A This directive sets the default algorithm for calculating the
213N/A expiration time for all documents in the affected realm. It can be
213N/A overridden on a type-by-type basis by the
213N/A directive. See the description of that directive for details about
211N/A the syntax of the argument, and the
213N/A <
A NAME="AltSyn">Alternate Interval Syntax</
A>
949N/A ><
SAMP>ExpiresDefault</
SAMP></
A>
144N/A ><
SAMP>ExpiresByType</
SAMP></
A>
260N/A directives can also be defined in a more readable syntax of the form:
260N/A <
DD><
CODE>ExpiresDefault "<base> [plus] {<num> <type>}*"
260N/A {<num> <type>}*"</
CODE>
219N/A where <base> is one of:
219N/A <
LI><
SAMP>access</
SAMP>
219N/A <
LI><
SAMP>now</
SAMP> (equivalent to '<
SAMP>access</
SAMP>')
219N/A <
LI><
SAMP>modification</
SAMP>
220N/A The '<
SAMP>plus</
SAMP>' keyword is optional. <num> should be an
979N/A integer value [acceptable to <
SAMP>atoi()</
SAMP>], and <type>
949N/A <
LI><
SAMP>months</
SAMP>
979N/A <
LI><
SAMP>minutes</
SAMP>
220N/A <
LI><
SAMP>seconds</
SAMP>
220N/A For example, any of the following directives can be used to make
623N/A documents expire 1 month after being accessed, by default:
220N/A <
DD><
CODE>ExpiresDefault "access plus 1 month"
221N/A ExpiresDefault "access plus 4 weeks"
221N/A ExpiresDefault "access plus 30 days"</
CODE>
221N/A The expiry time can be fine-tuned by adding several '<num>
336N/A <
DD><
CODE>ExpiresByType
text/
html "access plus 1 month 15 days 2 hours"
336N/A ExpiresByType
image/
gif "modification plus 5 hours 3 minutes"</
CODE>
336N/A Note that if you use a modification date based setting, the Expires
336N/A header will <
STRONG>not</
STRONG> be added to content that does
336N/A not come from a file on disk. This is due to the fact that there is
341N/A no modification time for such content.