0

It seems that Varnish is missing or not validating cache properly. When I try and purge my cache, I get 200 OK Cache successfully cleared, but my page does not update. I am simply making HTML changes to my footer.php (using WordPress) but they are not appearing. I checked my headers and they are as follows:

HTTP/1.1 200 OK
Server: nginx/1.6.0
Content-Type: text/html
Last-Modified: Wed, 23 Apr 2014 18:47:17 GMT
ETag: "53580ab5-2"
Content-Length: 2
Accept-Ranges: bytes
Date: Fri, 10 Oct 2014 15:53:28 GMT
X-Varnish: 21166333
Age: 0
Via: 1.1 varnish
Connection: keep-alive

The "ID of the request that populated the cache" is missing from the X-Varnish header.

So I checked the headers, running the command directly from my VPS where my website is hosted, and it seems to be working ok:

HTTP/1.1 200 OK
Server: nginx/1.6.0
Content-Type: text/html; charset=UTF-8
Vary: Accept-Encoding
X-Powered-By: PHP/5.4.33
X-Pingback: http://example.com/xmlrpc.php
Date: Fri, 10 Oct 2014 15:52:56 GMT
X-Varnish: 21166331 21166330
Age: 21
Via: 1.1 varnish
Connection: keep-alive

Here is my VCL file:

backend default {
  .host = "127.0.0.1";
  .port = "8080";
}

acl purge {
        "localhost";
        "127.0.0.1";
        "173.10.93.222";
}
sub vcl_recv {

if (req.request == "BAN") {
    error 200 "Cached Cleared Successfully.";
}

        if (req.request == "PURGE") {
                if (!client.ip ~ purge) {
                        error 405 "Not allowed.";
                }
                return(lookup);
        }
if (req.url ~ "^/$") {
               unset req.http.cookie;
            }
}
sub vcl_hit {
        if (req.request == "PURGE") {
                set obj.ttl = 0s;
                error 200 "Purged.";
        }
}
sub vcl_miss {
        if (req.request == "PURGE") {
                error 404 "Not in cache.";
        }
if (!(req.url ~ "wp-(login|admin)")) {
                        unset req.http.cookie;
                }
    if (req.url ~ "^/[^?]+.(jpeg|jpg|png|gif|ico|js|css|txt|gz|zip|lzma|bz2|tgz|tbz|html|htm)(\?.|)$") {
       unset req.http.cookie;
       set req.url = regsub(req.url, "\?.$", "");
    }
    if (req.url ~ "^/$") {
       unset req.http.cookie;
    }
}
sub vcl_fetch {
        if (req.url ~ "^/$") {
                unset beresp.http.set-cookie;
        }
        if (!(req.url ~ "wp-(login|admin)")) {
                unset beresp.http.set-cookie;
        }
}

When I check the website www.isvarnishworking.com I get the following:

Yes! Sort of! Varnish appears to be responding at that url, but the "Age" header is less than 1.

Some assistance would be appreciated, I have a feeling this is something simple. I should note this is running on an NGINX server.

My style.css seemed to update fine, just the DOM of the page is not updating.

sysadmin1138
  • 133,124
  • 18
  • 176
  • 300
David
  • 131
  • 2
  • 12
  • It might be worth checking that nginx is serving the changes before blaming Varnish. Use `curl 127.0.0.1:8080/footer.php` on the server or something like that. – Ladadadada Oct 10 '14 at 18:27

1 Answers1

1

Nevermind, it seems Varnish is working after the initial page load, but the reason my updated files weren't displaying is because of APC.

David
  • 131
  • 2
  • 12