<div class="gmail_quote">Hi<div><br></div><div>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 <a href="http://www.windows7news.com/magazine-homepage/" target="_blank">www.windows7news.com/magazine-homepage/</a> as it's homepage and is doing some magic within Wordpress to show this page when the page <a href="http://www.windows7news.com/" target="_blank">www.windows7news.com/</a> is requested i.e. the server doesn't know that <a href="http://www.windows7news.com/magazine-homepage/" target="_blank">www.windows7news.com/magazine-homepage/</a> needs purging.</div>
<div><br></div><div>I thought I'd temporariliy managed to fix this by adding:</div><div><br></div><div><div>sub vcl_recv {</div><div> <span style="white-space:pre-wrap"> </span>if (req.url ~ "^/") {</div>
<div> return(pass);</div><div> }</div><div>}</div></div><div><br></div><div>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?</div>
<div><br></div><div>Thanks in advance for any help.</div><div><br></div><div>My full VCL is below. If anyone has any Wordpress specific changes they'd like to share then please send them my way!</div><div><br></div>
<div>
Regards</div><div><br>EB</div><div><br></div><div>-----------------------------------------------------------------------------------------------------------------------------------</div><div><br></div><div><div>backend b96_30_20_4 {</div>
<div>.host = "96.30.20.4";</div><div>.port = "8080";</div><div>.probe = {</div><div> .url = "/";</div><div> .interval = 5s;</div><div> .timeout = 1 s;</div>
<div> .window = 5;</div><div> .threshold = 3;</div><div> }</div><div>// we include time outs so uploads don't time out</div><div> .connect_timeout = 600s;</div><div> .first_byte_timeout = 600s;</div>
<div> .between_bytes_timeout = 600s;</div><div>}</div><div><br></div><div>backend b96_30_20_5 {</div><div>.host = "96.30.20.5";</div><div>.port = "8080";</div><div>.probe = {</div><div> .url = "/";</div>
<div> .interval = 5s;</div><div> .timeout = 1 s;</div><div> .window = 5;</div><div> .threshold = 3;</div><div> }</div><div>// we include time outs so uploads don't time out</div>
<div> .connect_timeout = 600s;</div><div> .first_byte_timeout = 600s;</div><div> .between_bytes_timeout = 600s;</div><div>}</div><div><br></div><div>backend b96_30_20_6 {</div><div>.host = "96.30.20.6";</div><div>
.port = "8080";</div><div>.probe = {</div><div> .url = "/";</div><div> .interval = 5s;</div><div> .timeout = 1 s;</div><div> .window = 5;</div>
<div> .threshold = 3;</div><div> }</div><div>// we include time outs so uploads don't time out</div><div> .connect_timeout = 600s;</div><div> .first_byte_timeout = 600s;</div><div> .between_bytes_timeout = 600s;</div>
<div>}</div><div><br></div><div>backend b96_30_20_7 {</div><div>.host = "96.30.20.7";</div><div>.port = "8080";</div><div>.probe = {</div><div> .url = "/";</div><div> .interval = 5s;</div>
<div> .timeout = 1 s;</div><div> .window = 5;</div><div> .threshold = 3;</div><div> }</div><div>// we include time outs so uploads don't time out</div><div> .connect_timeout = 600s;</div>
<div> .first_byte_timeout = 600s;</div><div> .between_bytes_timeout = 600s;</div><div>}</div><div><br></div><div>backend b96_30_18_15 {</div><div>.host = "96.30.18.15";</div><div>.port = "8080";</div>
<div>
.probe = {</div><div> .url = "/";</div><div> .interval = 5s;</div><div> .timeout = 1 s;</div><div> .window = 5;</div><div> .threshold = 3;</div>
<div> }</div><div>// we include time outs so uploads don't time out</div><div> .connect_timeout = 600s;</div><div> .first_byte_timeout = 600s;</div><div> .between_bytes_timeout = 600s;</div><div>}</div><div><br></div>
<div>acl a96_30_20_4 {</div><div>"96.30.20.4";</div><div>}</div><div>acl a96_30_20_5 {</div><div>"96.30.20.5";</div><div>}</div><div>acl a96_30_20_6 {</div><div>"96.30.20.6";</div><div>}</div>
<div>acl a96_30_20_7 {</div><div>"96.30.20.7";</div><div>}</div><div>acl a96_30_18_15 {</div><div>"96.30.18.15";</div><div>}</div><div><br></div><div>acl purge {</div><div> "96.30.20.4";</div>
<div><span style="white-space:pre-wrap"> </span>"96.30.20.5";</div><div><span style="white-space:pre-wrap"> </span>"96.30.20.6";</div><div><span style="white-space:pre-wrap"> </span>"96.30.20.7";</div>
<div><span style="white-space:pre-wrap"> </span>"96.30.18.15";</div><div>}</div><div><br></div><div>sub vcl_recv {</div><div><span style="white-space:pre-wrap"> </span>if (server.ip ~ a96_30_20_4) {</div>
<div><span style="white-space:pre-wrap"> </span>set req.backend = b96_30_20_4;</div><div><span style="white-space:pre-wrap"> </span>}</div><div><span style="white-space:pre-wrap"> </span>if (server.ip ~ a96_30_20_5) {</div>
<div><span style="white-space:pre-wrap"> </span>set req.backend = b96_30_20_5;</div><div><span style="white-space:pre-wrap"> </span>}</div><div><span style="white-space:pre-wrap"> </span>if (server.ip ~ a96_30_20_6) {</div>
<div><span style="white-space:pre-wrap"> </span>set req.backend = b96_30_20_6;</div><div><span style="white-space:pre-wrap"> </span>}</div><div><span style="white-space:pre-wrap"> </span>if (server.ip ~ a96_30_20_7) {</div>
<div><span style="white-space:pre-wrap"> </span>set req.backend = b96_30_20_7;</div><div><span style="white-space:pre-wrap"> </span>}</div><div><span style="white-space:pre-wrap"> </span>if (server.ip ~ a96_30_18_15) {</div>
<div><span style="white-space:pre-wrap"> </span>set req.backend = b96_30_18_15;</div><div><span style="white-space:pre-wrap"> </span>}</div><div>}</div><div><br></div><div>sub vcl_recv {</div>
<div> if (req.request == "PURGE") {</div><div> if (!client.ip ~ purge) {</div><div> error 405 "Not allowed.";</div><div> }</div><div> return(lookup);</div>
<div> }</div><div><span style="white-space:pre-wrap"> </span>if (req.url ~ "^/") {</div><div> return(pass);</div><div> }</div><div><span style="white-space:pre-wrap"> </span>if (req.url ~ "^/forum/$") {</div>
<div> return(pass);</div><div> }</div><div><span style="white-space:pre-wrap"> </span>if (req.url ~ "^/$") {</div><div> unset req.http.cookie;</div><div>
}</div><div>}</div><div>sub vcl_hit {</div><div> if (req.request == "PURGE") {</div><div> set obj.ttl = 0s;</div><div> error 200 "Purged.";</div><div> }</div>
<div>}</div><div>sub vcl_miss {</div><div> if (req.request == "PURGE") {</div><div> error 404 "Not in cache.";</div><div> }</div><div><span style="white-space:pre-wrap"> </span>if (!(req.url ~ "wp-(login|admin)")) {</div>
<div> unset req.http.cookie;</div><div> }</div><div> if (req.url ~ "^/[^?]+.(jpeg|jpg|png|gif|ico|js|css|txt|gz|zip|lzma|bz2|tgz|tbz|html|htm)(\?.|)$") {</div><div> unset req.http.cookie;</div>
<div> set req.url = regsub(req.url, "\?.$", "");</div><div> }</div><div> if (req.url ~ "^/$") {</div><div> unset req.http.cookie;</div><div> }</div><div>}</div><div>sub vcl_fetch {</div>
<div> if (req.url ~ "^/$") {</div><div> unset beresp.http.set-cookie;</div><div> }</div><div>if (!(req.url ~ "wp-(login|admin)")) {</div><div> unset beresp.http.set-cookie;</div>
<div>}</div><div>}</div></div>
</div><br>