Help debugging cacheability / ttl information?

Denis Brækhus denis at startsiden.no
Thu Jan 31 14:17:22 CET 2008


Hi,

We have a setup with varnish in front of a lighttpd+fastcgi combo. For some reason or other the application doesn't send any cache control headers. Instead of doing the sensible thing (prodding the developers to fix it in the backend) I have taken it upon myself to fix it via VCL. 

However my feeble attempts at being smart have so far failed elegantly, and I am left scratching my head a bit.

What I really am looking for is some help with how to best debug the setup with regards to TTLs and cacheability. I'd like to be able to inspect a specific cached objects TTL to see if my "set obj.ttl" overrides actually work or not. What is the best way to do that? 

On the client I use firebug, so all headers and responess are readily available on that end. The reason I don't think everything is as it should is that the Age header is very low most of the time.

For the record we are still at varnish 1.0.4 and here is the current VCL (I've taken out the stuff that was obviously not working anyway) :

"
backend default {
        set backend.host = "127.0.0.1";
        set backend.port = "80";
}

sub vcl_recv {
    if (req.request == "GET" && req.http.cookie) {
        lookup;
    }
    if (req.request == "GET" && req.url ~ "\.(gif|jpg|swf|css|js)$") {
        lookup;
    }
}

sub vcl_fetch {
    if (obj.ttl < 120s) {
        set obj.ttl = 120s;
    }
    if (resp.http.Set-Cookie) {
        insert;
    }
}
"

Any help will be highly appreciated!

Regards
--
Denis



More information about the varnish-misc mailing list