170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
}
}
# Redirect everything under /code to the Fossil instance
location /code {
include local/code;
# Extended caching for URLs known to include unique IDs
location ~ /(artifact|doc|file|raw)/ {
include local/code;
add_header Cache-Control "public, max-age=31536000, immutable";
access_log off;
}
}
}
----
As you can see, this is a pure extension of [the basic nginx service
|
|
|
>
>
>
|
>
>
>
>
>
|
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
|
}
}
# Redirect everything under /code to the Fossil instance
location /code {
include local/code;
# Extended caching for URLs that include unique IDs
location ~ "/(artifact|doc|file|raw)/[0-9a-f]{40,64}" {
add_header Cache-Control "public, max-age=31536000, immutable";
include local/code;
access_log off;
}
# Lesser caching for URLs likely to be quasi-static
location ~* \.(css|gif|ico|js|jpg|png)$ {
add_header Vary Accept-Encoding;
include local/code;
access_log off;
expires 7d;
}
}
}
----
As you can see, this is a pure extension of [the basic nginx service
|
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
|
We separate that out because nginx refuses to inherit certain settings
between nested location blocks, so rather than repeat them, we extract
them to this separate file and include it from both locations where it’s
needed. You see this above where we set far-future expiration dates on
files served by Fossil via URLs that contain hashes that change when the
content changes. It tells your browser that the content of these URLs
can never change without the URL itself changing, which makes your
Fossil-based site considerably faster.(^Beware: If you use logical
versions in URLs like `/file/trunk/path/name/…` the rule above will
apply to them, too, requiring your users to toss the cache before
they’ll see updates to the referenced content. Trading off caching
versus the possibility of stale data is a delicate dance. You can make
this arbitrarily complex. You might give a cache time of a day or a week
for URLs more likely to change and reserve the really-long times for
those impossible to change without changing the URL.)
Similarly, the `local/generic` file referenced above helps us reduce unnecessary
repetition among the multiple sites this configuration hosts:
root /var/www/$host;
listen 80;
|
|
<
<
<
<
<
<
<
|
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
|
We separate that out because nginx refuses to inherit certain settings
between nested location blocks, so rather than repeat them, we extract
them to this separate file and include it from both locations where it’s
needed. You see this above where we set far-future expiration dates on
files served by Fossil via URLs that contain hashes that change when the
content changes. It tells your browser that the content of these URLs
can never change without the URL itself changing, which makes your
Fossil-based site considerably faster.
Similarly, the `local/generic` file referenced above helps us reduce unnecessary
repetition among the multiple sites this configuration hosts:
root /var/www/$host;
listen 80;
|