Support » Plugins and Hacks » Using nginx varnish, cache not being purged

Using nginx varnish, cache not being purged

  • I changed out our software over the last few days. Went from Apache to Varnish + Nginx + PHP-FPM with APC and Memcache. The performance difference is insane!

    But… new posts or changes to existing posts are not being reflected on the main page. If I make a change to a post, it appears that the post itself gets purged, but not the front page.

    I have “Enable varnish cache purging” checked, and the IP address of the varnish server entered. And like I said, the post itself seems to get purged.

    Anyone else run across this?

Viewing 7 replies - 1 through 7 (of 7 total)
  • My only suggestion would be to NOT cache your front page, since your setup should provide some level of caching for your front page without also caching in w3tc. Try it and let us know your results?

    Please keep this thread updated, I am following it, and am very interested in your setup for some future deployments. I have been holding off on testing that configuration until there is better support for nginx with w3tc.

    @gilligan, thanks for the suggestion. That does work for now.

    There are a few things that aren’t quite right with nginx, but for the most part I’m thrilled. For one, the menu bar across the top does not show up if I’m logged in.

    Another, more major problem is that wptouch pro, which is a mobile theme for phones, does not appear to work at all with this setup. I’m really hoping to get that one figured out!

    wptouch would rely on user-agent string interpretation & passing it to the plugin, so you should hit up the nginx forums to troubleshoot that issue. Having so many layers in play, it’s difficult to determine how that would get passed to and from varnish & nginx

    Do you really need memcache? I’d remove that from the mix if you don’t have your database server on a separate node.

    I found a better place in the stack to do the redirect: varnish.

    In sub vcl_recv, I added:

    if ( req.http.user-agent ~
              set req.http.newhost = regsub(req.http.host, "(www)?.(.*)", "http://m.2");
              error 750 req.http.newhost;

    And then

    sub vcl_error {
            if (obj.status == 750) {
              set obj.http.Location = obj.response;
              set obj.status = 302;

    I hope this helps someone else!

    Plugin Author Frederick Townes


    The next release improves varnish purging significantly.

    Thanks, Frederick! Is that release fairly imminent?

    Plugin Author Frederick Townes



Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Using nginx varnish, cache not being purged’ is closed to new replies.