1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
4 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
5 This file is generated from xml source: DO NOT EDIT
6 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
8 <title>mod_expires - Apache HTTP Server</title>
9 <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
10 <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
11 <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" />
12 <link href="../images/favicon.ico" rel="shortcut icon" /></head>
14 <div id="page-header">
15 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p>
16 <p class="apache">Apache HTTP Server Version 2.1</p>
17 <img alt="" src="../images/feather.gif" /></div>
18 <div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div>
20 <a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs-project/">Documentation</a> > <a href="../">Version 2.1</a> > <a href="./">Modules</a></div>
21 <div id="page-content">
22 <div id="preamble"><h1>Apache Module mod_expires</h1>
24 <p><span>Available Languages: </span><a href="../en/mod/mod_expires.html" title="English"> en </a> |
25 <a href="../ja/mod/mod_expires.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a></p>
27 <table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Generation of <code>Expires</code> HTTP headers according to
28 user-specified criteria</td></tr>
29 <tr><th><a href="module-dict.html#Status">Status:</a></th><td>Extension</td></tr>
30 <tr><th><a href="module-dict.html#ModuleIdentifier">Module Identifier:</a></th><td>expires_module</td></tr>
31 <tr><th><a href="module-dict.html#SourceFile">Source File:</a></th><td>mod_expires.c</td></tr></table>
34 <p>This module controls the setting of the <code>Expires</code>
35 HTTP header in server responses. The expiration date can set to
36 be relative to either the time the source file was last
37 modified, or to the time of the client access.</p>
39 <p>The <code>Expires</code> HTTP header is an instruction to
40 the client about the document's validity and persistence. If
41 cached, the document may be fetched from the cache rather than
42 from the source until this time has passed. After that, the
43 cache copy is considered "expired" and invalid, and a new copy
44 must be obtained from the source.</p>
46 <div id="quickview"><h3 class="directives">Directives</h3>
48 <li><img alt="" src="../images/down.gif" /> <a href="#expiresactive">ExpiresActive</a></li>
49 <li><img alt="" src="../images/down.gif" /> <a href="#expiresbytype">ExpiresByType</a></li>
50 <li><img alt="" src="../images/down.gif" /> <a href="#expiresdefault">ExpiresDefault</a></li>
54 <li><img alt="" src="../images/down.gif" /> <a href="#AltSyn">Alternate Interval Syntax</a></li>
56 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
58 <h2><a name="AltSyn" id="AltSyn">Alternate Interval Syntax</a></h2>
59 <p>The <code class="directive"><a href="#expiresdefault">ExpiresDefault</a></code> and
60 <code class="directive"><a href="#expiresbytype">ExpiresByType</a></code> directives
61 can also be defined in a more readable syntax of the form:</p>
63 <div class="example"><p><code>
64 ExpiresDefault "<base> [plus] {<num>
66 ExpiresByType type/encoding "<base> [plus]
67 {<num> <type>}*"
70 <p>where <base> is one of:</p>
73 <li><code>access</code></li>
75 <li><code>now</code> (equivalent to
76 '<code>access</code>')</li>
78 <li><code>modification</code></li>
81 <p>The <code>plus</code> keyword is optional. <num>
82 should be an integer value [acceptable to <code>atoi()</code>],
83 and <type> is one of:</p>
86 <li><code>years</code></li>
87 <li><code>months</code></li>
88 <li><code>weeks</code></li>
89 <li><code>days</code></li>
90 <li><code>hours</code></li>
91 <li><code>minutes</code></li>
92 <li><code>seconds</code></li>
95 <p>For example, any of the following directives can be used to
96 make documents expire 1 month after being accessed, by
99 <div class="example"><p><code>
100 ExpiresDefault "access plus 1 month"<br />
101 ExpiresDefault "access plus 4 weeks"<br />
102 ExpiresDefault "access plus 30 days"
105 <p>The expiry time can be fine-tuned by adding several
106 '<num> <type>' clauses:</p>
108 <div class="example"><p><code>
109 ExpiresByType text/html "access plus 1 month 15
111 ExpiresByType image/gif "modification plus 5 hours 3
115 <p>Note that if you use a modification date based setting, the
116 Expires header will <strong>not</strong> be added to content
117 that does not come from a file on disk. This is due to the fact
118 that there is no modification time for such content.</p>
120 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
121 <div class="directive-section"><h2><a name="ExpiresActive" id="ExpiresActive">ExpiresActive</a> <a name="expiresactive" id="expiresactive">Directive</a></h2>
122 <table class="directive">
123 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Enables generation of Expires
125 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>ExpiresActive On|Off</code></td></tr>
126 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
127 <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>Indexes</td></tr>
128 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
129 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_expires</td></tr>
131 <p>This directive enables or disables the generation of the
132 <code>Expires</code> header for the document realm in question.
133 (That is, if found in an <code>.htaccess</code> file, for
134 instance, it applies only to documents generated from that
135 directory.) If set to <code>Off</code>, no <code>Expires</code> header
136 will be generated for any document in the realm (unless overridden at
137 a lower level, such as an <code>.htaccess</code> file overriding a
138 server config file). If set to <code>On</code>, the header will be
139 added to served documents according to the criteria defined by the
140 <code class="directive"><a href="#expiresbytype">ExpiresByType</a></code> and
141 <code class="directive"><a href="#expiresdefault">ExpiresDefault</a></code> directives
144 <p>Note that this directive does not guarantee that an
145 <code>Expires</code> header will be generated. If the criteria
146 aren't met, no header will be sent, and the effect will be as
147 though this directive wasn't even specified.</p>
150 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
151 <div class="directive-section"><h2><a name="ExpiresByType" id="ExpiresByType">ExpiresByType</a> <a name="expiresbytype" id="expiresbytype">Directive</a></h2>
152 <table class="directive">
153 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Value of the Expires header configured
154 by MIME type</td></tr>
155 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>ExpiresByType <var>MIME-type</var>
156 <var><code>seconds</var></code></td></tr>
157 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
158 <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>Indexes</td></tr>
159 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
160 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_expires</td></tr>
162 <p>This directive defines the value of the <code>Expires</code>
163 header generated for documents of the specified type (<em>e.g.</em>,
164 <code>text/html</code>). The second argument sets the number of
165 seconds that will be added to a base time to construct the expiration
168 <p>The base time is either the last modification time of the
169 file, or the time of the client's access to the document. Which
170 should be used is specified by the
171 <code><var><code></var></code> field; <code>M</code>
172 means that the file's last modification time should be used as
173 the base time, and <code>A</code> means the client's access
174 time should be used.</p>
176 <p>The difference in effect is subtle. If <code>M</code> is used,
177 all current copies of the document in all caches will expire at
178 the same time, which can be good for something like a weekly
179 notice that's always found at the same URL. If <code>A</code> is
180 used, the date of expiration is different for each client; this
181 can be good for image files that don't change very often,
182 particularly for a set of related documents that all refer to
183 the same images (<em>i.e.</em>, the images will be accessed
184 repeatedly within a relatively short timespan).</p>
186 <div class="example"><h3>Example:</h3><p><code>
187 # enable expirations<br />
188 ExpiresActive On<br />
189 # expire GIF images after a month in the client's cache<br />
190 ExpiresByType image/gif A2592000<br />
191 # HTML documents are good for a week from the<br />
192 # time they were changed<br />
193 ExpiresByType text/html M604800
196 <p>Note that this directive only has effect if
197 <code>ExpiresActive On</code> has been specified. It overrides,
198 for the specified MIME type <em>only</em>, any expiration date
199 set by the <code class="directive"><a href="#expiresdefault">ExpiresDefault</a></code>
202 <p>You can also specify the expiration time calculation using
203 an <a href="#AltSyn">alternate syntax</a>, described earlier in
207 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
208 <div class="directive-section"><h2><a name="ExpiresDefault" id="ExpiresDefault">ExpiresDefault</a> <a name="expiresdefault" id="expiresdefault">Directive</a></h2>
209 <table class="directive">
210 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Default algorithm for calculating expiration time</td></tr>
211 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>ExpiresDefault <var><code>seconds</var></code></td></tr>
212 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
213 <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>Indexes</td></tr>
214 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
215 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_expires</td></tr>
217 <p>This directive sets the default algorithm for calculating the
218 expiration time for all documents in the affected realm. It can be
219 overridden on a type-by-type basis by the <code class="directive"><a href="#expiresbytype">ExpiresByType</a></code> directive. See the
220 description of that directive for details about the syntax of the
221 argument, and the <a href="#AltSyn">alternate syntax</a>
222 description as well.</p>
226 <div class="bottomlang">
227 <p><span>Available Languages: </span><a href="../en/mod/mod_expires.html" title="English"> en </a> |
228 <a href="../ja/mod/mod_expires.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a></p>
229 </div><div id="footer">
230 <p class="apache">Copyright 1999-2004 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
231 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div>