• Hello everyone!

    I recently made the varnish configuration on my server where I have 3 hosted domains (with wordpress).

    My server:
    2 cores 2GHZ
    4GB RAM
    Varnish 4 + MySQL 5.6 + Apache + PHP 5.5
    CentOS 7
    My default.vcl: http://pastebin.com/YQUZAad4
    Print of ‘varnishstat’: http://prntscr.com/bq50yc
    One of the sites that are on this server: http://bit.ly/29oGs21

    I have a VCL leaving the site very fast, fast even though WordPress use. When I publish something it does not update the site, maintains the previous cache, updated only when I restart the varnish “service varnish restart“.

    I was analyzing my .VCL and found the cause of the problem is this code here (into vcl_recv):

    if ( !( req.url ~ "wp-(login|admin)" )) {
      unset req.http.Cookie;
    }

    When I remove this code to post updates back to work and if I post it shows to everyone, if I delete it goes for all (users). Buuut the site is not as fast as before, and the Load server is high (Load Average 0.50~)

    Summing up.

    Without the informed code (Load Average 0:50 ~ 1 and exchange slow pages)
    With the informed code (Load Average 0:18 ~ 0:23 and exchange pages ‘ninja’)

    and

    Without the informed code (updated posts, it shows what was published instantly)
    With the informed code (cache posts, not updated when I make a new post)

    When I click publish with the plugin “Varnish HTTP Purge” enabled the site is slow and takes a few seconds to publish … still does not update the cache when the above code is in default.vcl.

    It would be very important that in the publication of some varnish station was “upgraded”. I appreciate any help !!!

    Thx from Brazil

    https://wordpress.org/plugins/varnish-http-purge/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Contributor Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    The plugin only officially supports Varnish 3, as I do not have a Varnish 4 set up to play on.

    This is the VCL we’re using:

    https://github.com/dreamhost/varnish-vcl-collection/blob/master/wordpress-example.vcl

    Can you manually run CURL -X PURGE http://domain.com/.* to flush your cache?

    You MAY need to put in a host param: curl -X PURGE "http://123.45.67.89/.*" -H "host:http://www.example.com"

    That would be the case if the Varnish service IP isn’t the same as the server, but it sounds like that’s not an issue for you.

    Try vcaching which support v4:
    https://wordpress.org/plugins/vcaching/

    Thread Starter Matheus Bavaresco

    (@genneral)

    Hi Mika.
    When i put the Curl X-PURGE i get this:

    <!DOCTYPE html>
    <html>
      <head>
        <title>200 Purged</title>
      </head>
      <body>
        <h1>Error 200 Purged</h1>
        <p>Purged</p>
        <h3>Guru Meditation:</h3>
        <p>XID: 791482</p>
        <hr>
        <p>Varnish cache server</p>
      </body>
    </html>

    I have an IP nat configured as default backend of Varnish, have 3 registered domains on the server and three “virtualhosts” using the same NAT IP.

    And @rubenvarnish This plugin has no effect on the site…not generates the VCL’s. I have an open topic in support of this plugin also ..

    Thread Starter Matheus Bavaresco

    (@genneral)

    Is it interesting I do a downgrade to the varnish 3? For with the current VCL I need to take a PURGE every time I publish something and this is out of the question ..

    Obs: That code curl -X PURGE "http://11.11.111.111/.*" -H "host:http://www.host.com" don’t purge the cache on my host, he didn’t do anything..

    Thread Starter Matheus Bavaresco

    (@genneral)

    Hi! Excuse me for so many posts in a row..but I think I found the problem (my mistake).

    I have three domains in this server, three virtualhosts (NameVirtualHosts) using the same IP NAT. But, i have one backend.

    backend default {
        .host = "MY IP NAT";
        .port = "8080";
        .connect_timeout = 600s;
        .first_byte_timeout = 600s;
        .between_bytes_timeout = 600s;
        .max_connections = 800;
    }

    All requests are being sent to a backend, when I delete the cache of varnish (makes PURGE) it goes on all sites..then, i need some like this to differentiate which site is being called..am i right?

    if (req.http.host == "siteone.com") {
             set req.http.host = "siteone.com";
             set req.http.X-Orig-Host = req.http.host;
             set req.backend = siteone;
             return (lookup);
    }
    if (req.http.host == "sitetwo.com") {
            set req.http.host = "sitetwo.com";
             set req.http.X-Orig-Host = req.http.host;
             set req.backend = sitetwo;
             return (lookup);
    }

    Ty!!!

    Plugin Contributor Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    That shouldn’t matter.

    If both CURL -X PURGE http://siteone.com/.* and CURL -X PURGE http://sitetwo.com/.* properly work via the command line, then the req host doesn’t matter UNLESS your wp-admin backend doesn’t match those URLs.

    Also I derped.

    curl -X PURGE "http://11.11.111.111/.*" -H "host:www.host.com"

    Thread Starter Matheus Bavaresco

    (@genneral)

    I got the same mistake again and the cache has not been purged:

    <!DOCTYPE html>
    <html>
      <head>
        <title>200 Purged</title>
      </head>
      <body>
        <h1>Error 200 Purged</h1>
        <p>Purged</p>
        <h3>Guru Meditation:</h3>
        <p>XID: 338027</p>
        <hr>
        <p>Varnish cache server</p>
      </body>
    </html>

    In fact the varnish is working very well, according to the rate of “hits” and “miss” by varnishstat. But one of my sites is updated twice a day, and if you have no automatic option to clear (purge) the cache, I need always be accessing the server and restartar the varnish … which is not cool.

    I’ll try setting the VCL using director’s and separate into 3 different backends to my site to see if I have results.

    For now, very grateful for the support !!!

    Txh from Brazil!

    Plugin Contributor Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    Error 200 is not an error, that’s a successful purge.

    But one of my sites is updated twice a day, and if you have no automatic option to clear (purge) the cache, I need always be accessing the server and restartar the varnish … which is not cool.

    The plugin will not have an automatic option for that. You’re supposed to script the expires into your VCL 🙂 But you can also make a cron job to do a manual purge, and that’s what I’m trying to get at here… If the error 200 (which is a success, yeah I know it’s stupid, not my call) is NOT flushing your cache, you have an issue with your VCL setup.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘By activating the "Purge" the site is slow’ is closed to new replies.