aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config/httpd.conf13
l---------public/views_cache1
2 files changed, 14 insertions, 0 deletions
diff --git a/config/httpd.conf b/config/httpd.conf
index 3bbe50fb3..6428a2006 100644
--- a/config/httpd.conf
+++ b/config/httpd.conf
@@ -32,6 +32,19 @@ RequestHeader add X-Forwarded-User %{RU}e
# files for archiving.
RewriteRule /files/(.+) http://files.whatdotheyknow.com/$1
+# Serve attachments directly from the cache, if possible.
+#
+# The file names are URL-encoded on disk, and sharded by the first
+# three digits of the request id, which is why this is as complicated
+# as it is. The RewriteMap directive makes the URL-escaping function
+# available to use in the other directives.
+#
+# The condition means that the rule will fire only if the cached
+# file exists.
+RewriteMap escape int:escape
+RewriteCond %{DOCUMENT_ROOT}/views_cache/request/$2/$1/${escape:$3} -f
+RewriteRule ^/request/((\d{1,3})\d*)/(response/\d+/attach/\d+/.+) /views_cache/request/$2/$1/${escape:$3} [L]
+
<IfModule mod_passenger.c>
# Set this to something like 100 if you have memory leak issues
PassengerMaxRequests 20
diff --git a/public/views_cache b/public/views_cache
new file mode 120000
index 000000000..ea65934d2
--- /dev/null
+++ b/public/views_cache
@@ -0,0 +1 @@
+../cache/views \ No newline at end of file