mod_expires.html revision d030d579df50673f566f5dbcd1904fd59cd310e0
10139N/A<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
10139N/A<HTML>
10139N/A <HEAD>
10139N/A <TITLE>Apache module mod_expires</TITLE>
10139N/A </HEAD>
10139N/A<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
10139N/A <BODY
10139N/A BGCOLOR="#FFFFFF"
10139N/A TEXT="#000000"
10139N/A LINK="#0000FF"
11195N/A VLINK="#000080"
10139N/A ALINK="#FF0000"
10139N/A >
12091N/A <!--#include virtual="header.html" -->
10139N/A <H1 ALIGN="CENTER">Module mod_expires</H1>
10139N/A <P>
10139N/A This module is contained in the <CODE>mod_expires.c</CODE> file, and
10139N/A is <STRONG>not</STRONG> compiled in by default. It provides for the
11838N/A generation of <CODE>Expires</CODE> headers according to user-specified
10142N/A criteria.
10139N/A </P>
11195N/A <H2>Summary</H2>
10139N/A <P>
11195N/A This module controls the setting of the <CODE>Expires</CODE> HTTP
10529N/A header in server responses. The expiration date can set to be
11195N/A relative to either the time the source file was last modified, or to
10139N/A the time of the client access.
11195N/A </P>
10139N/A <P>
11195N/A The <CODE>Expires</CODE> HTTP header is an instruction to the client
10139N/A about the document's validity and persistence. If cached, the document
11195N/A may be fetched from the cache rather than from the source until this
10139N/A time has passed. After that, the cache copy is considered
11195N/A &quot;expired&quot; and invalid, and a new copy must be obtained from
10139N/A the source.
11195N/A </P>
10139N/A <H2>Directives</H2>
11195N/A <P>
11352N/A <MENU>
11352N/A <LI><A
12015N/A HREF="#expiresactive"
12014N/A >ExpiresActive</A>
10139N/A </LI>
10139N/A <LI><A
10139N/A HREF="#expiresbytype"
10139N/A >ExpiresByType</A>
10139N/A </LI>
10139N/A <LI><A
10139N/A HREF="#expiresdefault"
10139N/A >ExpiresDefault</A>
10139N/A </LI>
10139N/A </MENU>
10139N/A <HR>
10139N/A <H2><A NAME="expiresactive">
10139N/A ExpiresActive directive
10139N/A </A></H2>
10139N/A <!--%plaintext &lt;?INDEX {\tt ExpiresActive} directive&gt; -->
10139N/A <P>
10139N/A <A
10139N/A HREF="directive-dict.html#Syntax"
10139N/A REL="Help"
10139N/A ><STRONG>Syntax:</STRONG></A> ExpiresActive <EM>boolean</EM>
10139N/A <BR>
10139N/A <A
10139N/A HREF="directive-dict.html#Context"
10139N/A REL="Help"
10139N/A ><STRONG>Context:</STRONG></A> server config, virtual host, directory,
10139N/A .htaccess
10139N/A <BR>
10139N/A <A
10139N/A HREF="directive-dict.html#Override"
10139N/A REL="Help"
10139N/A ><STRONG>Override:</STRONG></A> Indexes
10139N/A <BR>
10139N/A <A
10139N/A HREF="directive-dict.html#Status"
10139N/A REL="Help"
10139N/A ><STRONG>Status:</STRONG></A> Extension
10139N/A <BR>
10139N/A <A
10139N/A HREF="directive-dict.html#Module"
10139N/A REL="Help"
10139N/A ><STRONG>Module:</STRONG></A> mod_expires
10139N/A </P>
10139N/A <P>
10139N/A This directive enables or disables the generation of the
10139N/A <CODE>Expires</CODE> header for the document realm in question. (That
10139N/A is, if found in an <CODE>.htaccess</CODE> file, for instance, it
10139N/A applies only to documents generated from that directory.) If set to
10139N/A <EM><CODE>Off</CODE></EM>, no <CODE>Expires</CODE> header will be
10139N/A generated for any document in the realm (unless overridden at a lower
10139N/A level, such as an <CODE>.htaccess</CODE> file overriding a server
10139N/A config file). If set to <EM><CODE>On</CODE></EM>, the header will be
10139N/A added to served documents according to the criteria defined by the
10139N/A <A
10139N/A HREF="#expiresbytype"
10142N/A >ExpiresByType</A>
10139N/A and
10139N/A <A
11195N/A HREF="#expiresdefault"
10139N/A >ExpiresDefault</A>
10139N/A directives (<EM>q.v.</EM>).
10139N/A </P>
10139N/A <P>
11195N/A Note that this directive does not guarantee that an
10139N/A <CODE>Expires</CODE> header will be generated. If the criteria aren't
11195N/A met, no header will be sent, and the effect will be as though this
10139N/A directive wasn't even specified.
10139N/A </P>
10139N/A <HR>
11352N/A <H2><A NAME="expiresbytype">
12014N/A ExpiresByType directive
10139N/A </A></H2>
10139N/A <!--%plaintext &lt;?INDEX {\tt ExpiresByType} directive&gt; -->
10139N/A <P>
10139N/A <A
10139N/A HREF="directive-dict.html#Syntax"
10139N/A REL="Help"
10139N/A ><STRONG>Syntax:</STRONG></A> ExpiresByType <EM>mime-type
10139N/A &lt;code&gt;seconds</EM>
10139N/A <BR>
10139N/A <A
10139N/A HREF="directive-dict.html#Context"
10139N/A REL="Help"
10139N/A ><STRONG>Context:</STRONG></A> server config, virtual host, directory,
10139N/A .htaccess
10139N/A <BR>
10139N/A <A
10139N/A HREF="directive-dict.html#Override"
10139N/A REL="Help"
10139N/A ><STRONG>Override:</STRONG></A> Indexes
10139N/A <BR>
10139N/A <A
10139N/A HREF="directive-dict.html#Status"
10139N/A REL="Help"
10139N/A ><STRONG>Status:</STRONG></A> Extension
10139N/A <BR>
10139N/A <A
10139N/A HREF="directive-dict.html#Module"
10139N/A REL="Help"
10139N/A ><STRONG>Module:</STRONG></A> mod_expires
10139N/A </P>
10139N/A <P>
10139N/A This directive defines the value of the <CODE>Expires</CODE> header
11271N/A generated for documents of the specified type (<EM>e.g.</EM>,
10139N/A <CODE>text/html</CODE>). The second argument sets the number of
10139N/A seconds that will be added to a base time to construct the expiration
10139N/A date.
10139N/A </P>
10139N/A <P>
10139N/A The base time is either the last modification time of the file, or the
10139N/A time of the client's access to the document. Which should be used is
10139N/A specified by the <CODE><EM>&lt;code&gt;</EM></CODE> field;
10139N/A <STRONG>M</STRONG> means that the file's last modification time should
10139N/A be used as the base time, and <STRONG>A</STRONG> means the client's
10139N/A access time should be used.
10139N/A </P>
10139N/A <P>
10139N/A The difference in effect is subtle. If <EM>M</EM> is used, all current
10139N/A copies of the document in all caches will expire at the same time,
10139N/A which can be good for something like a weekly notice that's always
10139N/A found at the same URL. If <EM>A</EM> is used, the date of expiration
10139N/A is different for each client; this can be good for image files that
10139N/A don't change very often, particularly for a set of related documents
10139N/A that all refer to the same images (<EM>i.e.</EM>, the images will be
10139N/A accessed repeatedly within a relatively short timespan).
10139N/A </P>
10139N/A <P>
10139N/A <STRONG>Example:</STRONG>
10139N/A </P>
10139N/A <P>
10139N/A <PRE>
10139N/A ExpiresActive On # enable expirations
10139N/A ExpiresByType image/gif A2592000 # expire GIF images after a month
10139N/A # in the client's cache
10139N/A ExpiresByType text/html M604800 # HTML documents are good for a
10139N/A # week from the time they were
10139N/A # changed, period
10139N/A </PRE>
10139N/A </P>
10139N/A <P>
10139N/A Note that this directive only has effect if <CODE>ExpiresActive
10139N/A On</CODE> has been specified. It overrides, for the specified MIME
10139N/A type <EM>only</EM>, any expiration date set by the
10139N/A <A
10139N/A HREF="#expiresdefault"
10139N/A >ExpiresDefault</A>
10139N/A directive.
10139N/A </P>
10139N/A <P>
10139N/A You can also specify the expiration time calculation using an
10139N/A <A
10139N/A HREF="#AltSyn"
10139N/A >alternate syntax</A>,
10139N/A described later in this document.
10139N/A </P>
10139N/A <HR>
10139N/A <H2><A NAME="expiresdefault">
10139N/A ExpiresDefault directive
10139N/A </A></H2>
10139N/A <!--%plaintext &lt;?INDEX {\tt ExpiresDefault} directive&gt; -->
10139N/A <P>
10139N/A <A
10139N/A HREF="directive-dict.html#Syntax"
10139N/A REL="Help"
10139N/A ><STRONG>Syntax:</STRONG></A> ExpiresDefault <EM>&lt;code&gt;seconds</EM>
10139N/A <BR>
10139N/A <A
10139N/A HREF="directive-dict.html#Context"
10139N/A REL="Help"
10139N/A ><STRONG>Context:</STRONG></A> server config, virtual host, directory,
10139N/A .htaccess
10139N/A <BR>
10139N/A <A
10139N/A HREF="directive-dict.html#Override"
10139N/A REL="Help"
10139N/A ><STRONG>Override:</STRONG></A> Indexes
10139N/A <BR>
10139N/A <A
10139N/A HREF="directive-dict.html#Status"
12091N/A REL="Help"
12091N/A ><STRONG>Status:</STRONG></A> Extension
12014N/A <BR>
12014N/A <A
12014N/A HREF="directive-dict.html#Module"
11922N/A REL="Help"
11922N/A ><STRONG>Module:</STRONG></A> mod_expires
11922N/A </P>
11922N/A <P>
11416N/A This directive sets the default algorithm for calculating the
11416N/A expiration time for all documents in the affected realm. It can be
11352N/A overridden on a type-by-type basis by the
11352N/A <A
11299N/A HREF="#expiresbytype"
11299N/A >ExpiresByType</A>
11271N/A directive. See the description of that directive for details about
11271N/A the syntax of the argument, and the
11271N/A <A
11271N/A HREF="#AltSyn"
11271N/A >alternate syntax</A>
11271N/A description as well.
11245N/A </P>
11245N/A <HR>
11245N/A <H2>
11271N/A <A NAME="AltSyn">Alternate Interval Syntax</A>
11271N/A </H2>
11195N/A <P>
11195N/A The
11195N/A <A
11271N/A HREF="#expiresdefault"
11017N/A ><SAMP>ExpiresDefault</SAMP></A>
11017N/A and
11017N/A <A
10529N/A HREF="#expiresbytype"
10529N/A ><SAMP>ExpiresByType</SAMP></A>
10454N/A directives can also be defined in a more readable syntax of the form:
10454N/A </P>
10281N/A <DL>
10281N/A <DD><CODE>ExpiresDefault "&lt;base&gt; [plus] {&lt;num&gt; &lt;type&gt;}*"
10139N/A <BR>
10139N/A ExpiresByType type/encoding "&lt;base&gt; [plus]
10139N/A {&lt;num&gt; &lt;type&gt;}*"</CODE>
10139N/A </DD>
10139N/A </DL>
10139N/A <P>
10139N/A where &lt;base&gt; is one of:
10139N/A </P>
10139N/A <MENU>
10139N/A <LI><SAMP>access</SAMP>
10139N/A </LI>
10139N/A <LI><SAMP>now</SAMP> (equivalent to '<SAMP>access</SAMP>')
10139N/A </LI>
10139N/A <LI><SAMP>modification</SAMP>
10139N/A </LI>
10139N/A </MENU>
10139N/A <P>
10139N/A The '<SAMP>plus</SAMP>' keyword is optional. &lt;num&gt; should be an
10139N/A integer value [acceptable to <SAMP>atoi()</SAMP>], and &lt;type&gt;
10139N/A is one of:
10139N/A </P>
10139N/A <MENU>
10139N/A <LI><SAMP>years</SAMP>
10139N/A </LI>
10139N/A <LI><SAMP>months</SAMP>
10139N/A </LI>
10139N/A <LI><SAMP>weeks</SAMP>
10139N/A </LI>
10139N/A <LI><SAMP>days</SAMP>
10139N/A </LI>
10139N/A <LI><SAMP>hours</SAMP>
10139N/A </LI>
10139N/A <LI><SAMP>minutes</SAMP>
10139N/A </LI>
10139N/A <LI><SAMP>seconds</SAMP>
10139N/A </LI>
10139N/A </MENU>
10139N/A <P>
10139N/A For example, any of the following directives can be used to make
10139N/A documents expire 1 month after being accessed, by default:
10139N/A </P>
10139N/A <DL>
10139N/A <DD><CODE>ExpiresDefault "access plus 1 month"
10139N/A <BR>
10139N/A ExpiresDefault "access plus 4 weeks"
10139N/A <BR>
10139N/A ExpiresDefault "access plus 30 days"</CODE>
10139N/A </DD>
10139N/A </DL>
10139N/A <P>
10139N/A The expiry time can be fine-tuned by adding several '&lt;num&gt;
10139N/A &lt;type&gt;' clauses:
10139N/A </P>
10139N/A <DL>
10139N/A <DD><CODE>ExpiresByType text/html "access plus 1 month 15 days 2 hours"
10139N/A <BR>
10139N/A ExpiresByType image/gif "modification plus 5 hours 3 minutes"</CODE>
10139N/A </DD>
10139N/A </DL>
10139N/A
10139N/A <!--#include virtual="footer.html" -->
10139N/A </BODY>
10139N/A</HTML>
10139N/A