Fwd: [Wordpress]homepage not purging

Everton Blair everton at connectedinternet.co.uk
Fri Jul 8 12:38:57 CEST 2011


Hi

I've just started using Varnish with Wordpress/W3TC, and all is ok, apart
from my homepage not purging when an update is made e.g. a new post.  I
think this might be because my homepage is using a static page
www.windows7news.com/magazine-homepage/ as it's homepage and is doing some
magic within Wordpress to show this page when the page
www.windows7news.com/is requested i.e. the server doesn't know that
www.windows7news.com/magazine-homepage/ needs purging.

I thought I'd temporariliy managed to fix this by adding:

sub vcl_recv {
       if (req.url ~ "^/") {
               return(pass);
            }
}

But I only managed to turn the cache off completely.  Is there anyway to
tell Varnish to always purge the homepage if there's a change?

Thanks in advance for any help.

My full VCL is below.  If anyone has any Wordpress specific changes they'd
like to share then please send them my way!

 Regards

EB

-----------------------------------------------------------------------------------------------------------------------------------

backend b96_30_20_4 {
.host = "96.30.20.4";
.port = "8080";
.probe = {
                .url = "/";
                .interval = 5s;
                .timeout = 1 s;
                .window = 5;
                .threshold = 3;
  }
// we include time outs so uploads don't time out
 .connect_timeout = 600s;
 .first_byte_timeout = 600s;
 .between_bytes_timeout = 600s;
}

backend b96_30_20_5 {
.host = "96.30.20.5";
.port = "8080";
.probe = {
                .url = "/";
                .interval = 5s;
                .timeout = 1 s;
                .window = 5;
                .threshold = 3;
  }
// we include time outs so uploads don't time out
 .connect_timeout = 600s;
 .first_byte_timeout = 600s;
 .between_bytes_timeout = 600s;
}

backend b96_30_20_6 {
.host = "96.30.20.6";
.port = "8080";
.probe = {
                .url = "/";
                .interval = 5s;
                .timeout = 1 s;
                .window = 5;
                .threshold = 3;
  }
// we include time outs so uploads don't time out
 .connect_timeout = 600s;
 .first_byte_timeout = 600s;
 .between_bytes_timeout = 600s;
}

backend b96_30_20_7 {
.host = "96.30.20.7";
.port = "8080";
.probe = {
                .url = "/";
                .interval = 5s;
                .timeout = 1 s;
                .window = 5;
                .threshold = 3;
  }
// we include time outs so uploads don't time out
 .connect_timeout = 600s;
 .first_byte_timeout = 600s;
 .between_bytes_timeout = 600s;
}

backend b96_30_18_15 {
.host = "96.30.18.15";
.port = "8080";
 .probe = {
                .url = "/";
                .interval = 5s;
                .timeout = 1 s;
                .window = 5;
                .threshold = 3;
  }
// we include time outs so uploads don't time out
 .connect_timeout = 600s;
 .first_byte_timeout = 600s;
 .between_bytes_timeout = 600s;
}

acl a96_30_20_4 {
"96.30.20.4";
}
acl a96_30_20_5 {
"96.30.20.5";
}
acl a96_30_20_6 {
"96.30.20.6";
}
acl a96_30_20_7 {
"96.30.20.7";
}
acl a96_30_18_15 {
"96.30.18.15";
}

acl purge {
        "96.30.20.4";
 "96.30.20.5";
"96.30.20.6";
"96.30.20.7";
 "96.30.18.15";
}

sub vcl_recv {
if (server.ip ~ a96_30_20_4) {
 set req.backend = b96_30_20_4;
}
if (server.ip ~ a96_30_20_5) {
 set req.backend = b96_30_20_5;
}
if (server.ip ~ a96_30_20_6) {
 set req.backend = b96_30_20_6;
}
if (server.ip ~ a96_30_20_7) {
 set req.backend = b96_30_20_7;
}
if (server.ip ~ a96_30_18_15) {
 set req.backend = b96_30_18_15;
}
}

sub vcl_recv {
        if (req.request == "PURGE") {
                if (!client.ip ~ purge) {
                        error 405 "Not allowed.";
                }
                return(lookup);
        }
if (req.url ~ "^/") {
               return(pass);
            }
if (req.url ~ "^/forum/$") {
               return(pass);
            }
if (req.url ~ "^/$") {
               unset req.http.cookie;
            }
}
sub vcl_hit {
        if (req.request == "PURGE") {
                set obj.ttl = 0s;
                error 200 "Purged.";
        }
}
sub vcl_miss {
        if (req.request == "PURGE") {
                error 404 "Not in cache.";
        }
if (!(req.url ~ "wp-(login|admin)")) {
                 unset req.http.cookie;
                }
    if (req.url ~
"^/[^?]+.(jpeg|jpg|png|gif|ico|js|css|txt|gz|zip|lzma|bz2|tgz|tbz|html|htm)(\?.|)$")
{
       unset req.http.cookie;
       set req.url = regsub(req.url, "\?.$", "");
    }
    if (req.url ~ "^/$") {
       unset req.http.cookie;
    }
}
sub vcl_fetch {
        if (req.url ~ "^/$") {
                unset beresp.http.set-cookie;
        }
if (!(req.url ~ "wp-(login|admin)")) {
                        unset beresp.http.set-cookie;
}
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20110708/bf4bd761/attachment-0003.html>


More information about the varnish-misc mailing list