Merge lp:~tribaal/ubumirror/really-cache-debs-longer into lp:ubumirror

Proposed by Chris Glass
Status: Merged
Merged at revision: 76
Proposed branch: lp:~tribaal/ubumirror/really-cache-debs-longer
Merge into: lp:ubumirror
Diff against target: 49 lines (+18/-7)
1 file modified
apache2-ubuntu-mirror.conf (+18/-7)
To merge this branch: bzr merge lp:~tribaal/ubumirror/really-cache-debs-longer
Reviewer Review Type Date Requested Status
Ubumirror Developers Pending
Review via email: mp+222452@code.launchpad.net

Description of the change

The previous change introducing more aggressive caching for deb files was reverted (probably during a merge), so this reintroduces the 2 weeks timeout for *.deb files.

Since the deb files are versionned (their URL is constant for a given version), there is no reason not to set the cache timeout to "a long time". 2 weeks should be long enough for most of the regular updates to be held in memory for in-between caches, but it could even be set to much longer (or even non-expiring) quite safely.

To post a comment you must log in.
76. By Chris Glass

Use the expire module instead of just setting headers.

77. By Chris Glass

It is actually acceptable to serve stale content in this case - we don't need to force
proxies to refresh debs since they most likely won't change anyway.

78. By Chris Glass

Tune the cache behavior a little better.
The expires module sets expire time as well as max-header, no need to specify
it any further.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'apache2-ubuntu-mirror.conf'
2--- apache2-ubuntu-mirror.conf 2014-06-08 08:09:28 +0000
3+++ apache2-ubuntu-mirror.conf 2014-06-09 06:04:28 +0000
4@@ -1,7 +1,7 @@
5 # Example apache configuration for the ubuscript mirror.
6 # This will serve the default mirror directory on port 80 with a crude virtualhost.
7 # Don't forget to allow serving from /srv in /etc/apache2/apache2.conf, and
8-# to enable the "headers" module.
9+# to enable the "headers" and "expires" modules.
10
11 <VirtualHost *:80>
12 #ServerAdmin REPLACE_ME_WITH_ADMIN_EMAIL
13@@ -17,19 +17,30 @@
14
15 # Munge the Cache-Control/Expires response headers to try make
16 # transparent proxy servers DTRT.
17+ # This is used by the main Ubuntu archives.
18 <Files ~ "Release(\.gpg)?|Packages\.(bz2|gz)|Sources\.(bz2|gz)?$">
19 ExpiresActive On
20 ExpiresDefault "modification plus 3300 seconds"
21+ # In case a shared cache keeps a copy of the file, explicitely
22+ # set the expiry time.
23 Header append Cache-Control "s-maxage=3300"
24+ # Proxies (shared caches) must re-obtain the file if it's older
25+ # than s-maxage (they can never serve it if it's stale).
26 Header append Cache-Control "proxy-revalidate"
27+ # It's ok to serve the same content so several different users.
28+ Header append Cache-Control "public"
29 </Files>
30
31- # Don't cache HTML files as long (1 hour). This includes the indexes!
32- # This makes caching much more agressive, but may result in updates
33- # being delayed by this max-age value.
34- #<FilesMatch "\.(html|torrent|gz|xz|bz|bz2|dsc|iso|gif|torrent)$">
35- # Header set Cache-Control "max-age=3600, public, must-revalidate"
36- #</FilesMatch>
37+ # Set public cache control and a max age of 2 weeks for the debs and
38+ # other files with a versionned URL.
39+ <FilesMatch "\.(deb|iso|torrent|zsync)$">
40+ ExpiresActive On
41+ # Keep the file for two weeks - no matter if it's been modified
42+ # recently or not.
43+ ExpiresDefault "access plus 1209600 seconds"
44+ # It's ok to share the same content between users.
45+ Header append Cache-Control "public"
46+ </FilesMatch>
47
48 # Possible values include: debug, info, notice, warn, error, crit,
49 # alert, emerg.

Subscribers

People subscribed via source and target branches

to status/vote changes: