obj.status and obj.cacheable in varnish 2.1

David Murphy David at firechaser.com
Tue Apr 13 08:52:21 CEST 2010


Snippet from my vcl working under 2.1, which includes some debug header responses ( http://varnish-cache.org/wiki/VCLExampleHitMissHeader ) to see what's going in:

  # Varnish determined the object was not cacheable
    if (!beresp.cacheable) {
        set beresp.http.X-Cacheable = "NO:Not Cacheable";

    # You don't wish to cache content for logged in users
    } elsif(req.http.Cookie ~"(UserID|_session)") {
        set beresp.http.X-Cacheable = "NO:Got Session";
        return(pass);

    # You are respecting the Cache-Control=private header from the backend
    } elsif ( beresp.http.Cache-Control ~ "private") {
        set beresp.http.X-Cacheable = "NO:Cache-Control=private";
        return(pass);

    # You are extending the lifetime of the object artificially
    } elsif ( beresp.ttl < 1s ) {
        set beresp.ttl   = 5s;
        set beresp.grace = 5s;
        set beresp.http.X-Cacheable = "YES:FORCED";

   # Varnish determined the object was cacheable
    } else {
	set beresp.http.X-Cacheable = "YES";
    }

Best, David
________________________________________
From: Mahesh Ollalwar [mahesho at rediff.co.in]
Sent: 13 April 2010 07:42
To: David Murphy; varnish-misc at varnish-cache.org
Subject: Re: obj.status and obj.cacheable in varnish 2.1

Thanks David,

What about setting TTL in vcl_fetch

Like,

                        set obj.http.Cache-Control = "max-age=432000";
                        set obj.ttl = 5d;

Thanks,
Mahesh.

On Tuesday 13 April 2010 12:05 PM, David Murphy wrote:
Hi Mahesh

obj.* is called beresp.* in vcl_fetch in Varnish 2.1.

Best, David

On 13 Apr 2010, at 08:10, Mahesh Ollalwar wrote:

Hi,

I'm getting below errors in Varnish 2.1 whereas it was working in the older versions.

Message from VCC-compiler:
Variable 'obj.cacheable' not accessible in method 'vcl_fetch'.
At: (input Line 349 Pos 14)
        if (!obj.cacheable) {
-------------#############---
Running VCC-compiler failed, exit 1

Message from VCC-compiler:
Variable 'obj.status' not accessible in method 'vcl_fetch'.
At: (input Line 357 Pos 13)
        if (obj.status == 500 || obj.status == 501 || obj.status == 502 || obj.status == 503 || obj.status == 504 || obj.status == 404){
------------##########------------------------------------------------------------------------------------------------------------------
Running VCC-compiler failed, exit 1

Can anyone help me ?

Thanks,
Mahesh.


_______________________________________________
varnish-misc mailing list
varnish-misc at varnish-cache.org<mailto:varnish-misc at varnish-cache.org>
http://lists.varnish-cache.org/mailman/listinfo/varnish-misc


---------
David Murphy
Technical Director
Firechaser Limited
78 York Street
London W1H 1DP

0870 735 0800
www.firechaser.com<http://www.firechaser.com>








_______________________________________________
varnish-misc mailing list
varnish-misc at varnish-cache.org<mailto:varnish-misc at varnish-cache.org>
http://lists.varnish-cache.org/mailman/listinfo/varnish-misc





More information about the varnish-misc mailing list