summaryrefslogtreecommitdiff
path: root/pod/nginx/ngx_http_headers_module.pod
blob: 6bbac6a2367ae949cf51f81fdbdea5c630feddbe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
=encoding utf-8

=head1 NAME

ngx_http_headers_module - Module ngx_http_headers_module




=head1



The C<ngx_http_headers_module> module allows adding
the C<Expires> and C<Cache-Control> header
fields, and arbitrary fields, to a response header.




=head1 Example Configuration




    
    expires    24h;
    expires    modified +24h;
    expires    @24h;
    expires    0;
    expires    -1;
    expires    epoch;
    expires    $expires;
    add_header Cache-Control private;






=head1 Directives

=head2 add_header


B<syntax:> add_header I<
I<C<name>> I<C<value>>
[C<always>]>



B<context:> I<http>


B<context:> I<server>


B<context:> I<location>


B<context:> I<if in location>





Adds the specified field to a response header provided that
the response code equals 200, 201 (1.3.10), 204, 206, 301, 302, 303, 304,
307 (1.1.16, 1.0.13), or 308 (1.13.0).
Parameter value can contain variables.





There could be several C<add_header> directives.
These directives are inherited from the previous configuration level
if and only if there are no C<add_header> directives
defined on the current level.





If the C<always> parameter is specified (1.7.5),
the header field will be added regardless of the response code.







=head2 add_trailer


B<syntax:> add_trailer I<
I<C<name>> I<C<value>>
[C<always>]>



B<context:> I<http>


B<context:> I<server>


B<context:> I<location>


B<context:> I<if in location>



This directive appeared in version 1.13.2.





Adds the specified field to the end of a response provided that
the response code equals 200, 201, 206, 301, 302, 303, 307, or 308.
Parameter value can contain variables.





There could be several C<add_trailer> directives.
These directives are inherited from the previous configuration level
if and only if there are no C<add_trailer> directives
defined on the current level.





If the C<always> parameter is specified
the specified field will be added regardless of the response code.







=head2 expires


B<syntax:> expires I<[C<modified>] I<C<time>>>


B<syntax:> expires I<
    C<epoch> E<verbar>
    C<max> E<verbar>
    C<off>>


B<default:> I<off>


B<context:> I<http>


B<context:> I<server>


B<context:> I<location>


B<context:> I<if in location>





Enables or disables adding or modifying the C<Expires>
and C<Cache-Control> response header fields provided that
the response code equals 200, 201 (1.3.10), 204, 206, 301, 302, 303, 304,
307 (1.1.16, 1.0.13), or 308 (1.13.0).
The parameter can be a positive or negative
L<time|syntax>.





The time in the C<Expires> field is computed as a sum of the
current time and I<C<time>> specified in the directive.
If the C<modified> parameter is used (0.7.0, 0.6.32)
then the time is computed as a sum of the file’s modification time and
the I<C<time>> specified in the directive.





In addition, it is possible to specify a time of day using
the “C<@>” prefix (0.7.9, 0.6.34):

    
    expires @15h30m;







The contents of the C<Cache-Control> field depends
on the sign of the specified time:

=over




=item *

time is negative — C<Cache-Control: no-cache>.



=item *

time is positive or zero —
C<Cache-Control: max-age=I<C<t>>>,
where I<C<t>> is a time specified in the directive, in seconds.



=back







The C<epoch> parameter sets C<Expires>
to the value “C<Thu, 01 Jan 1970 00:00:01 GMT>”,
and C<Cache-Control> to “C<no-cache>”.





The C<max> parameter sets C<Expires>
to the value “C<Thu, 31 Dec 2037 23:55:55 GMT>”,
and C<Cache-Control> to 10 years.





The C<off> parameter disables adding or modifying the
C<Expires> and C<Cache-Control> response
header fields.





The last parameter value can contain variables (1.7.9):

    
    map $sent_http_content_type $expires {
        default         off;
        application/pdf 42d;
        ~image/         max;
    }
    
    expires $expires;