Skip to content
Browse files

modifications to fix issue #39 with ban versus purge

  • Loading branch information...
1 parent eb84cec commit 3b7a7cb7393f84ddff62258b871e16f540012317 @cd34 cd34 committed Feb 7, 2013
Showing with 13 additions and 17 deletions.
  1. +3 −0 README.markdown
  2. +6 −0 readme.txt
  3. +3 −16 wordpress.vcl
  4. +1 −1 wp-varnish.php
View
3 README.markdown
@@ -78,6 +78,9 @@ Screenshots
Changelog
---------
+### 0.5
+* New .vcl to fix purge as per Issue #39, Thanks Ed Cooper
+
### 0.4
* added rule to skip caching 404s in vcl
View
6 readme.txt
@@ -71,6 +71,9 @@ surfer's IP rather than the server's IP.
== Changelog ==
+= 0.5 =
+* New .vcl to fix purge as per Issue #39, Thanks Ed Cooper
+
= 0.4 =
* added rule to skip caching 404s in vcl
@@ -94,6 +97,9 @@ surfer's IP rather than the server's IP.
== Upgrade Notice ==
+= 0.5 =
+* New .vcl to fix purge as per Issue #39, Thanks Ed Cooper
+
= 0.3 =
* Varnish PURGE configuration must support regex. wp-varnish will
sometimes request with regex for special purges like refreshing
View
19 wordpress.vcl
@@ -8,11 +8,12 @@ acl purge {
}
sub vcl_recv {
- if (req.request == "PURGE") {
+ if (req.request == "BAN") {
if(!client.ip ~ purge) {
error 405 "Not allowed.";
}
- return(lookup);
+ ban("req.url ~ "+req.url+" && req.http.host == "+req.http.host);
+ error 200 "Banned.";
}
if (req.request != "GET" &&
@@ -37,20 +38,6 @@ sub vcl_recv {
return (lookup);
}
-sub vcl_hit {
- if (req.request == "PURGE") {
- purge;
- error 200 "Purged.";
- }
-}
-
-sub vcl_miss {
- if (req.request == "PURGE") {
- purge;
- error 200 "Purged.";
- }
-}
-
sub vcl_fetch {
if (beresp.status == 404) {
set beresp.ttl = 0m;
View
2 wp-varnish.php
@@ -391,7 +391,7 @@ function WPVarnishPurgeObject($wpv_url) {
$out = "purge req.url ~ ^$wpv_url && req.http.host == $wpv_host\n";
}
} else {
- $out = "PURGE $wpv_url HTTP/1.0\r\n";
+ $out = "BAN $wpv_url HTTP/1.0\r\n";
$out .= "Host: $wpv_host\r\n";
$out .= "User-Agent: WordPress-Varnish plugin\r\n";
$out .= "Connection: Close\r\n\r\n";

0 comments on commit 3b7a7cb

Please sign in to comment.
Something went wrong with that request. Please try again.