]> granicus.if.org Git - apache/blob - docs/manual/mod/mod_expires.xml
Update the stylesheet reference to the new language-specific version.
[apache] / docs / manual / mod / mod_expires.xml
1 <?xml version="1.0"?>
2 <!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
3 <?xml-stylesheet type="text/xsl" href="../style/manual.en.xsl"?>
4 <modulesynopsis>
5
6 <name>mod_expires</name>
7 <description>Generation of
8     <code>Expires</code> HTTP headers according to user-specified
9     criteria</description>
10 <status>Extension</status>
11 <sourcefile>mod_expires.c</sourcefile>
12 <identifier>expires_module</identifier>
13
14 <summary>
15     <p>This module controls the setting of the <code>Expires</code>
16     HTTP header in server responses. The expiration date can set to
17     be relative to either the time the source file was last
18     modified, or to the time of the client access.</p>
19
20     <p>The <code>Expires</code> HTTP header is an instruction to
21     the client about the document's validity and persistence. If
22     cached, the document may be fetched from the cache rather than
23     from the source until this time has passed. After that, the
24     cache copy is considered "expired" and invalid, and a new copy
25     must be obtained from the source.</p>
26 </summary>
27
28 <section id="AltSyn"><title>Alternate Interval
29     Syntax</title>
30
31     <p>The <directive module="mod_expires">ExpiresDefault</directive> and 
32     <directive module="mod_expires">ExpiresByType</directive> directives
33     can also be defined in a more readable syntax of the form:</p>
34
35 <example>
36        ExpiresDefault "&lt;base&gt; [plus] {&lt;num&gt;
37       &lt;type&gt;}*"<br />
38        ExpiresByType type/encoding "&lt;base&gt; [plus]
39       {&lt;num&gt; &lt;type&gt;}*"
40 </example>
41
42     <p>where &lt;base&gt; is one of:</p>
43
44     <ul>
45       <li><code>access</code></li>
46
47       <li><code>now</code> (equivalent to
48       '<code>access</code>')</li>
49
50       <li><code>modification</code></li>
51     </ul>
52
53     <p>The '<code>plus</code>' keyword is optional. &lt;num&gt;
54     should be an integer value [acceptable to <code>atoi()</code>],
55     and &lt;type&gt; is one of:</p>
56
57     <ul>
58       <li><code>years</code></li>
59
60       <li><code>months</code></li>
61
62       <li><code>weeks</code></li>
63
64       <li><code>days</code></li>
65
66       <li><code>hours</code></li>
67
68       <li><code>minutes</code></li>
69
70       <li><code>seconds</code></li>
71     </ul>
72
73     <p>For example, any of the following directives can be used to
74     make documents expire 1 month after being accessed, by
75     default:</p>
76
77 <example>
78        ExpiresDefault "access plus 1 month"<br />
79        ExpiresDefault "access plus 4 weeks"<br />
80        ExpiresDefault "access plus 30 days"
81 </example>
82
83     <p>The expiry time can be fine-tuned by adding several
84     '&lt;num&gt; &lt;type&gt;' clauses:</p>
85
86 <example>
87 ExpiresByType text/html "access plus 1 month 15
88       days 2 hours"<br />
89        ExpiresByType image/gif "modification plus 5 hours 3
90       minutes"
91 </example>
92
93     <p>Note that if you use a modification date based setting, the
94     Expires header will <strong>not</strong> be added to content
95     that does not come from a file on disk. This is due to the fact
96     that there is no modification time for such content.</p>
97 </section>
98
99 <directivesynopsis>
100 <name>ExpiresActive</name>
101 <description>Enables generation of <code>Expires</code> headers</description>
102 <syntax>ExpiresActive On|Off</syntax>
103 <contextlist><context>server config</context>
104 <context>virtual host</context><context>directory</context>
105 <context>.htaccess</context></contextlist>
106 <override>Indexes</override>
107
108 <usage>
109     <p>This directive enables or disables the generation of the
110     <code>Expires</code> header for the document realm in question.
111     (That is, if found in an <code>.htaccess</code> file, for
112     instance, it applies only to documents generated from that
113     directory.) If set to <em><code>Off</code></em>, no
114     <code>Expires</code> header will be generated for any document
115     in the realm (unless overridden at a lower level, such as an
116     <code>.htaccess</code> file overriding a server config file).
117     If set to <em><code>On</code></em>, the header will be added to
118     served documents according to the criteria defined by the 
119     <directive module="mod_expires">ExpiresByType</directive> and 
120     <directive module="mod_expires">ExpiresDefault</directive> directives
121     (<em>q.v.</em>).</p>
122
123     <p>Note that this directive does not guarantee that an
124     <code>Expires</code> header will be generated. If the criteria
125     aren't met, no header will be sent, and the effect will be as
126     though this directive wasn't even specified.</p>
127 </usage>
128 </directivesynopsis>
129
130 <directivesynopsis>
131 <name>ExpiresByType</name>
132 <description>Value of the <code>Expires</code> header configured
133 by MIME type</description>
134 <syntax>ExpiresByType
135     <em>MIME-type &lt;code&gt;seconds</em></syntax>
136 <contextlist><context>server config</context>
137 <context>virtual host</context><context>directory</context>
138 <context>.htaccess</context></contextlist>
139 <override>Indexes</override>
140
141 <usage>
142     <p>This directive defines the value of the <code>Expires</code>
143     header generated for documents of the specified type
144     (<em>e.g.</em>, <code>text/html</code>). The second argument
145     sets the number of seconds that will be added to a base time to
146     construct the expiration date.</p>
147
148     <p>The base time is either the last modification time of the
149     file, or the time of the client's access to the document. Which
150     should be used is specified by the
151     <code><em>&lt;code&gt;</em></code> field; <strong>M</strong>
152     means that the file's last modification time should be used as
153     the base time, and <strong>A</strong> means the client's access
154     time should be used.</p>
155
156     <p>The difference in effect is subtle. If <em>M</em> is used,
157     all current copies of the document in all caches will expire at
158     the same time, which can be good for something like a weekly
159     notice that's always found at the same URL. If <em>A</em> is
160     used, the date of expiration is different for each client; this
161     can be good for image files that don't change very often,
162     particularly for a set of related documents that all refer to
163     the same images (<em>i.e.</em>, the images will be accessed
164     repeatedly within a relatively short timespan).</p>
165
166     <p><strong>Example:</strong></p>
167 <example>
168 # enable expirations<br />
169 ExpiresActive On<br />
170 # expire GIF images after a month in the client's cache<br />
171 ExpiresByType image/gif A2592000<br />
172 # HTML documents are good for a week from the time they were changed<br />
173 ExpiresByType text/html M604800
174 </example>
175
176     <p>Note that this directive only has effect if
177     <code>ExpiresActive On</code> has been specified. It overrides,
178     for the specified MIME type <em>only</em>, any expiration date
179     set by the <directive module="mod_expires">ExpiresDefault</directive>
180     directive.</p>
181
182     <p>You can also specify the expiration time calculation using
183     an <a href="#AltSyn">alternate syntax</a>, described earlier in
184     this document.</p>
185 </usage>
186 </directivesynopsis>
187
188 <directivesynopsis>
189 <name>ExpiresDefault</name>
190 <description>Default algorithm for calculating expiration time</description>
191 <syntax>ExpiresDefault <em>&lt;code&gt;seconds</em></syntax>
192 <contextlist><context>server config</context>
193 <context>virtual host</context><context>directory</context>
194 <context>.htaccess</context></contextlist>
195 <override>Indexes</override>
196
197 <usage>
198     <p>This directive sets the default algorithm for calculating the
199     expiration time for all documents in the affected realm. It can be
200     overridden on a type-by-type basis by the <directive
201     module="mod_expires">ExpiresByType</directive> directive. See the
202     description of that directive for details about the syntax of the
203     argument, and the <a href="#AltSyn">alternate syntax</a>
204     description as well.</p>
205 </usage>
206 </directivesynopsis>
207 </modulesynopsis>
208