Purge not working well
-
Hello,
I have Varnish running on my server and it is caching correctly, but I can only purge “Purge Cache (All Pages)” and when I update a Woocommerce product it only cleans the homepage cache and no other URL, including the respective product page.
I really don’t know what I’m doing wrong.
My vcl config is the following:
backend default { .host = "111.11.111.11"; (my IP) .port = "8080"; .first_byte_timeout = 10s; .connect_timeout = 300s; .between_bytes_timeout = 5s; } acl purge { "111.11.111.11"; "localhost"; "127.0.0.1"; "::1"; }
varnish.params file:
VARNISH_LISTEN_PORT=6081 # Admin interface listen address and port VARNISH_ADMIN_LISTEN_ADDRESS=127.0.0.1 VARNISH_ADMIN_LISTEN_PORT=6082
My nginx setup:
if ($host = "mydomain.com") { set $PROXY_SCHEME "http"; set $PROXY_TO_PORT 6081; set $PROXY_DOMAIN_OR_IP "111.11.111.11"; }
Purge code:
sub vcl_recv { if (req.method == "PURGE" || req.method == "BAN") { # If the IP isn't a match, we can't flush cache. if (!client.ip ~ purge) { return (synth(405, "This IP is not allowed to send PURGE requests.")); } # If we're trying to regex, then we need to use the ban calls: if (req.http.X-Purge-Method == "regex") { ban("obj.http.x-url ~ " + req.url + " && obj.http.x-host ~ " + req.http.host); return (synth(200, "Purged")); } # Backported catch for exact cache flush calls: if (req.http.X-Purge-Method == "exact") { ban("obj.http.x-url == " + req.url + " && obj.http.X-Req-Host == " + req.http.host); return (synth(200, "Purged")); } # Otherwise, we strip the query params and flush as is: set req.url = regsub(req.url, "\?.*$", ""); return (purge); } } sub vcl_purge { set req.method = "GET"; set req.http.X-Purger = "Purged"; set req.http.X-Purge = "Yes"; return (restart); } sub vcl_backend_response { set beresp.http.x-url = bereq.url; set beresp.http.x-host = bereq.http.host; } sub vcl_deliver { unset resp.http.x-url; unset resp.http.x-host; }
Your plugin settings:
Set Custom IP: 111.11.111.11 (my IP)Best regards,
The page I need help with: [log in to see the link]
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Purge not working well’ is closed to new replies.