aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorSeb Bacon <seb.bacon@gmail.com>2012-03-09 11:48:38 +0000
committerSeb Bacon <seb.bacon@gmail.com>2012-03-13 13:55:47 +0000
commit76de470b1424be57934e58275a6116afb8eb9b3c (patch)
tree6ed9df78a8acac8278776c831ae6eb08383d935c /lib
parent17373088052029db46f6f8a6243901e442f6015c (diff)
first stab at sending PURGE requests to upstream varnish for request pages. Next step: making it asynchronous, e.g. with a queue of things to purge via a cron job.
Diffstat (limited to 'lib')
-rw-r--r--lib/varnish_purge.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/varnish_purge.rb b/lib/varnish_purge.rb
new file mode 100644
index 000000000..ef0cbd7ea
--- /dev/null
+++ b/lib/varnish_purge.rb
@@ -0,0 +1,11 @@
+require 'open-uri'
+
+def purge(url)
+ config = MySociety::Config.load_default()
+ varnish_url = config['VARNISH_URL']
+ url = "#{varnish_url}#{url}"
+ result = open(url).read
+ if result != "OK"
+ raise
+ end
+end