diff options
-rw-r--r-- | app/controllers/request_controller.rb | 8 | ||||
-rw-r--r-- | doc/CHANGES.md | 7 | ||||
-rw-r--r-- | doc/INSTALL-exim4.md | 17 | ||||
-rw-r--r-- | lib/quiet_opener.rb | 6 |
4 files changed, 26 insertions, 12 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index aa770e151..2f5b4d643 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -46,7 +46,13 @@ class RequestController < ApplicationController end def show - medium_cache + if !MySociety::Config.get('VARNISH_HOST').nil? + # If varnish is set up to accept PURGEs, then cache for a + # long time + long_cache + else + medium_cache + end @locale = self.locale_from_params() PublicBody.with_locale(@locale) do diff --git a/doc/CHANGES.md b/doc/CHANGES.md index bdc811a21..0abbeec82 100644 --- a/doc/CHANGES.md +++ b/doc/CHANGES.md @@ -57,7 +57,12 @@ you leave `VARNISH_HOST` blank, it will have no effect. Finally, you should install the `purge-varnish` init script that's provided in `ugly` format at `config/purge-varnish-debian.ugly` to ensure the - purge queue is emptied regularly. + purge queue is emptied regularly. Once deployed, you should also + check your production log for lines starting `PURGE:` to ensure the + purges are successful (a failure will typically be due to a + misconfigured Varnish). If purges are unsuccessful, the conseqence + is that individual request pages that are served to anonymous users + will be up to 24 hours out of date. * Administrators are now assumed to log in using standard user accounts with superuser privileges (see 'Administrator Privileges' in diff --git a/doc/INSTALL-exim4.md b/doc/INSTALL-exim4.md index 84f105c57..91c3506d3 100644 --- a/doc/INSTALL-exim4.md +++ b/doc/INSTALL-exim4.md @@ -40,17 +40,20 @@ content: ^foi\\+.*: |/path/to/alaveteli/software/script/mailin -You should also configure exim to discard any messages sent to the `BLACKHOLE_PREFIX` -address, whose default value is 'do-not-reply-to-this-address'. For example, add the -following to config/aliases: +You should also configure exim to discard any messages sent to the +`BLACKHOLE_PREFIX` address, whose default value is +'do-not-reply-to-this-address'. For example, add the following to +config/aliases: # We use this for envelope from for some messages where we don't care about delivery do-not-reply-to-this-address: :blackhole: -If you want to make use of the automatic bounce-message handling, then set the `TRACK_SENDER_EMAIL` -address to be filtered through `script/handle-mail-replies`. Messages that are not bounces or -out-of-office autoreplies will be forwarded to `FORWARD_NONBOUNCE_RESPONSES_TO`. For example, -in WhatDoTheyKnow the configuration looks like this: +If you want to make use of the automatic bounce-message handling, then +set the `TRACK_SENDER_EMAIL` address to be filtered through +`script/handle-mail-replies`. Messages that are not bounces or +out-of-office autoreplies will be forwarded to +`FORWARD_NONBOUNCE_RESPONSES_TO`. For example, in WhatDoTheyKnow the +configuration looks like this: raw_team: [a list of people on the team] team: |/path/to/alaveteli/software/script/handle-mail-replies diff --git a/lib/quiet_opener.rb b/lib/quiet_opener.rb index 2f78f76ad..f313b303c 100644 --- a/lib/quiet_opener.rb +++ b/lib/quiet_opener.rb @@ -24,12 +24,12 @@ def quietly_try_to_purge(host, url) } end rescue OpenURI::HTTPError, SocketError, Errno::ETIMEDOUT, Errno::ECONNREFUSED, Errno::EHOSTUNREACH - Rails.logger.warn("Unable to reach host #{host}") + Rails.logger.warn("PURGE: Unable to reach host #{host}") end if result == "200" - Rails.logger.info("Purged URL #{url} at #{host}: #{result}") + Rails.logger.info("PURGE: Purged URL #{url} at #{host}: #{result}") else - Rails.logger.warn("Unable to purge URL #{url} at #{host}: status #{result}") + Rails.logger.warn("PURGE: Unable to purge URL #{url} at #{host}: status #{result}") end return result end |