• 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)
  • Thread Starter leomp203

    (@leomp203)

    Checking cache status page gives me these results:

    Cache Service	Nginx caching service is running but is unable to cache your site.
    
    Remote IP	Your Proxy IP address is set to 111.11.111.11 but a proxy (like Cloudflare or Sucuri) has not been detected. This is mostly harmless, but if you have issues with your cache not emptying when you make a post, you may need to remove the IP. Please check with your webhost or server admin before doing so.
    Nginx	Your server is running Nginx.
    
    DreamHost	This site is hosted on DreamHost (as DreamPress). The results of this scan will be accurate. (It is not hosted in Dreamhost, it's just a header inserted by the VCL file)
    
    Age Headers	Your site is returning proper "Age" headers.
    
    No Cookies	No active cookies have been detected on your site. You may safely ignore any warnings about cookies set by plugins or themes, as your server has properly accounted for them.
    
    Plugin Check	Error: Plugin data was empty.
    
    Theme Check	No installed themes were found on the known conflicts list.
    Plugin Contributor Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    I’m actually a little surprised as your server, on DreamPress, should not be running NGINX. We moved everything to Varnish. Also we don’t allow people to manage their own Varnish rules … So clearly I have a bug in that check.

    Also the domain you put in your original post isn’t a valid domain (not registered at all) so I can’t even double check what’s going on there.

    > Plugin Check Error: Plugin data was empty.

    And that’s super weird too. I didn’t think it was possible to get that error.

    But… Sadly I cannot help people write and debug their own Varnish rules. It’s outside the scope of that I can support.

    I did work with Varnish and we all came up with a solid VCL – https://www.varnish-software.com/developers/tutorials/configuring-varnish-wordpress/#the-wordpress-vcl-file – so I can recommend that.

    Thread Starter leomp203

    (@leomp203)

    Hi,

    My site is not hosted in DreamPress, it’s just my VCL that has this line (I think is better to disable it):

    # Add powered by
    set resp.http.X-Powered-By = “DreamPress”;

    Thread Starter leomp203

    (@leomp203)

    I am running Apache with Engintron WHM plugin

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Purge not working well’ is closed to new replies.