[Plugin: W3 Total Cache] Varnish PURGE – Varnish as proxy
-
Hi there,
I’m using Varnish & W3TC.I want to be able to purge Varnish from W3TC.
Here the VCL which is advice for PURGE on Varnish website: https://www.varnish-cache.org/docs/trunk/tutorial/purging.html
acl purge { "localhost"; "192.168.55.0"/24; } sub vcl_recv { # allow PURGE from localhost and 192.168.55... if (req.request == "PURGE") { if (!client.ip ~ purge) { error 405 "Not allowed."; } return (lookup); } } sub vcl_hit { if (req.request == "PURGE") { purge; error 200 "Purged."; } } sub vcl_miss { if (req.request == "PURGE") { purge; error 200 "Purged."; } }
As you can see, PURGE on Varnish 3.0 is based on hash definition because PURGE operation is on hit / miss.
Also, the default VCL for hash sub-routine is :
sub vcl_hash { hash_data(req.url); if (req.http.host) { hash_data(req.http.host); } else { hash_data(server.ip); } return (hash); }
As you can see, the hash operation is based on the HTTP Host or IP. Because, +99% of our HTTP Clients use domain.tld, the hash is really based on HTTP Host.
The problem is, that W3TC use Varnish servers IP to send the PURGE HTTP Request.
Example :
– Send HTTP Purge to https://w.x.y.z/my-post (Where w.x.y.z) is a Varnish IP.In this case, Varnish try to get object from cache using the w.x.y.z & my-post.
This couldn’t work..So,
W3TC to be more generic have to deal with the Varnish IP because an IT could have many Varnish server. But, It should deal also with the “WordPress Address” define in the general panel of WP Admin.Also,
Here an functional example with cURL in CLI.
– curl -X PURGE -x https://w.x.y.z:80 https://domain.tld/my-postPS : I could use “domain.tld” inside Varnish server declaration. But in this case, what about an IT with 1 or + Varnish server with a Load Balancer before Varnish cluster ?
Armetiz.
- The topic ‘[Plugin: W3 Total Cache] Varnish PURGE – Varnish as proxy’ is closed to new replies.