Hello

I've been testing a simple txt page to confirm that when viewed by one browser 
(and cached in Varnish) that it is delivered as a Varnish cached file to a 
second browser.

My test is very simple: I have both Chrome and Firefox browsers open, and am 
trying access http:127.0.0.1/test.txt

1. Restart varnishd + apache2
2. Clear cookies/browser cache in obth browsers
3. Visit http:127.0.0.1/test.txt in Chrome and confirm via varnishtop -b -i 
TxURL that /text.txt has been cached

===
list length 2 
     1.00 TxURL          /robots.txt
     1.00 TxURL          /favicon.ico
===

4.Then visit same URL in Firefox

Now, the header results from (4) when I reach /test.txt (but already cached in 
Varnish) is

X-Cacheable     YES
Date    Sat, 13 Mar 2010 11:33:22 GMT
X-Varnish       1385957804
Age     43
Via     1.1 varnish
X-Cache MISS

Then if I hit refresh on this page (not force reload) I get 

X-Cacheable     YES
Date    Sat, 13 Mar 2010 11:34:15 GMT
X-Varnish       1385957805
Age     43
Via     1.1 varnish
X-Cache HIT

Note that there is only a single X-Varnish request number (1385957805) even 
though we get X-Cache: HIT

If I refresh again I get  the same results, but if I force reload (shift + 
reload) I get:

X-Cacheable     YES
Date    Sat, 13 Mar 2010 11:36:28 GMT
X-Varnish       1385957807 1385957804
Age     187
Via     1.1 varnish
Connection      keep-alive
X-Cache HIT

My VCL file is below:

===============

 GNU nano 2.0.9                        File: /etc/varnish/default.vcl           
                                             

backend default {
.host = "127.0.0.1";
.port = "8080";
.connect_timeout = 600s;
.first_byte_timeout = 600s;
.between_bytes_timeout = 600s;
}

sub vcl_recv {
unset req.http.cookie;
lookup;
}

sub vcl_fetch {
unset obj.http.Set-Cookie;

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

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

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

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

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

    deliver;
}

===============


Thanks for any assistance.

David
_______________________________________________
varnish-misc mailing list
[email protected]
http://lists.varnish-cache.org/mailman/listinfo/varnish-misc

Reply via email to