Fossil SCM

Made the URL matcher more specific in the nginx doc when showing how to get long expiration times on URLs known to yield unchanging content so we can drop the warning about it affecting URLs more likley to change. Added a second example for images, CSS, JS and such to show how you might handle these differently, addressing the core issue by example than by prose warning.

wyoung 2023-05-03 11:03 trunk
Commit f77ab1970c55c75a831dde2de977803aa18f902711b2967febf6b6735a940b51
1 file changed +12 -11
--- www/server/debian/nginx.md
+++ www/server/debian/nginx.md
@@ -172,15 +172,23 @@
172172
173173
# Redirect everything under /code to the Fossil instance
174174
location /code {
175175
include local/code;
176176
177
- # Extended caching for URLs known to include unique IDs
178
- location ~ /(artifact|doc|file|raw)/ {
179
- include local/code;
177
+ # Extended caching for URLs that include unique IDs
178
+ location ~ "/(artifact|doc|file|raw)/[0-9a-f]{40,64}" {
180179
add_header Cache-Control "public, max-age=31536000, immutable";
180
+ include local/code;
181
+ access_log off;
182
+ }
183
+
184
+ # Lesser caching for URLs likely to be quasi-static
185
+ location ~* \.(css|gif|ico|js|jpg|png)$ {
186
+ add_header Vary Accept-Encoding;
187
+ include local/code;
181188
access_log off;
189
+ expires 7d;
182190
}
183191
}
184192
}
185193
186194
----
@@ -200,18 +208,11 @@
200208
them to this separate file and include it from both locations where it’s
201209
needed. You see this above where we set far-future expiration dates on
202210
files served by Fossil via URLs that contain hashes that change when the
203211
content changes. It tells your browser that the content of these URLs
204212
can never change without the URL itself changing, which makes your
205
-Fossil-based site considerably faster.(^Beware: If you use logical
206
-versions in URLs like `/file/trunk/path/name/…` the rule above will
207
-apply to them, too, requiring your users to toss the cache before
208
-they’ll see updates to the referenced content. Trading off caching
209
-versus the possibility of stale data is a delicate dance. You can make
210
-this arbitrarily complex. You might give a cache time of a day or a week
211
-for URLs more likely to change and reserve the really-long times for
212
-those impossible to change without changing the URL.)
213
+Fossil-based site considerably faster.
213214
214215
Similarly, the `local/generic` file referenced above helps us reduce unnecessary
215216
repetition among the multiple sites this configuration hosts:
216217
217218
root /var/www/$host;
218219
--- www/server/debian/nginx.md
+++ www/server/debian/nginx.md
@@ -172,15 +172,23 @@
172
173 # Redirect everything under /code to the Fossil instance
174 location /code {
175 include local/code;
176
177 # Extended caching for URLs known to include unique IDs
178 location ~ /(artifact|doc|file|raw)/ {
179 include local/code;
180 add_header Cache-Control "public, max-age=31536000, immutable";
 
 
 
 
 
 
 
 
181 access_log off;
 
182 }
183 }
184 }
185
186 ----
@@ -200,18 +208,11 @@
200 them to this separate file and include it from both locations where it’s
201 needed. You see this above where we set far-future expiration dates on
202 files served by Fossil via URLs that contain hashes that change when the
203 content changes. It tells your browser that the content of these URLs
204 can never change without the URL itself changing, which makes your
205 Fossil-based site considerably faster.(^Beware: If you use logical
206 versions in URLs like `/file/trunk/path/name/…` the rule above will
207 apply to them, too, requiring your users to toss the cache before
208 they’ll see updates to the referenced content. Trading off caching
209 versus the possibility of stale data is a delicate dance. You can make
210 this arbitrarily complex. You might give a cache time of a day or a week
211 for URLs more likely to change and reserve the really-long times for
212 those impossible to change without changing the URL.)
213
214 Similarly, the `local/generic` file referenced above helps us reduce unnecessary
215 repetition among the multiple sites this configuration hosts:
216
217 root /var/www/$host;
218
--- www/server/debian/nginx.md
+++ www/server/debian/nginx.md
@@ -172,15 +172,23 @@
172
173 # Redirect everything under /code to the Fossil instance
174 location /code {
175 include local/code;
176
177 # Extended caching for URLs that include unique IDs
178 location ~ "/(artifact|doc|file|raw)/[0-9a-f]{40,64}" {
 
179 add_header Cache-Control "public, max-age=31536000, immutable";
180 include local/code;
181 access_log off;
182 }
183
184 # Lesser caching for URLs likely to be quasi-static
185 location ~* \.(css|gif|ico|js|jpg|png)$ {
186 add_header Vary Accept-Encoding;
187 include local/code;
188 access_log off;
189 expires 7d;
190 }
191 }
192 }
193
194 ----
@@ -200,18 +208,11 @@
208 them to this separate file and include it from both locations where it’s
209 needed. You see this above where we set far-future expiration dates on
210 files served by Fossil via URLs that contain hashes that change when the
211 content changes. It tells your browser that the content of these URLs
212 can never change without the URL itself changing, which makes your
213 Fossil-based site considerably faster.
 
 
 
 
 
 
 
214
215 Similarly, the `local/generic` file referenced above helps us reduce unnecessary
216 repetition among the multiple sites this configuration hosts:
217
218 root /var/www/$host;
219

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button