Cacheability - changed in Varnish 2?

Anton Stonor stonorn at giraffen.dk
Wed Jan 28 11:23:08 CET 2009


Poul-Henning Kamp wrote:

> Can you get me varnishlog of such a request ?  I'm not able to
> tell from your description which path we're talking about.

Sure, just thought this was intended behavior so I wouldn't bore with 
details. Here we go.

Running Varnish 2.0.2 on Ubuntu, has tested on Debian Etch 64bit as well.

Failure:

     9 SessionOpen  c 127.0.0.1 41768 127.0.0.1:8000
     9 ReqStart     c 127.0.0.1 41768 1998529221
     9 RxRequest    c GET
     9 RxURL        c /test_varnish
     9 RxProtocol   c HTTP/1.1
     9 RxHeader     c Host: localhost:8000
     9 RxHeader     c User-Agent: Mozilla/5.0 (X11; U; Linux i686; 
en-US; rv:1.9.0.5) Gecko/2008121622 Ubuntu/8.10 (intrepid) Firefox/3.0.5
     9 RxHeader     c Accept: 
text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
     9 RxHeader     c Accept-Language: en-us,en;q=0.5
     9 RxHeader     c Accept-Encoding: gzip,deflate
     9 RxHeader     c Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
     9 RxHeader     c Keep-Alive: 300
     9 RxHeader     c Connection: keep-alive
     9 VCL_call     c recv
     9 VCL_return   c lookup
     9 VCL_call     c hash
     9 VCL_return   c hash
     9 HitPass      c 1998529216
     9 VCL_call     c pass
     9 VCL_return   c pass
     9 Backend      c 10 backend_0 backend_0
    10 TxRequest    - GET
    10 TxURL        - /test_varnish
    10 TxProtocol   - HTTP/1.1
    10 TxHeader     - Host: localhost:8000
    10 TxHeader     - User-Agent: Mozilla/5.0 (X11; U; Linux i686; 
en-US; rv:1.9.0.5) Gecko/2008121622 Ubuntu/8.10 (intrepid) Firefox/3.0.5
    10 TxHeader     - Accept: 
text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    10 TxHeader     - Accept-Language: en-us,en;q=0.5
    10 TxHeader     - Accept-Encoding: gzip,deflate
    10 TxHeader     - Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    10 TxHeader     - X-Varnish: 1998529221
    10 TxHeader     - X-Forwarded-For: 127.0.0.1
    10 RxProtocol   - HTTP/1.1
    10 RxStatus     - 200
    10 RxResponse   - OK
    10 RxHeader     - Server: Zope/(Zope 2.10.6-final, python 2.4.5, 
linux2) ZServer/1.1 Plone/3.1.5.1
    10 RxHeader     - Date: Wed, 28 Jan 2009 10:13:23 GMT
    10 RxHeader     - Content-Length: 4
    10 RxHeader     - Content-Type: text/plain; charset=utf-8
     9 ObjProtocol  c HTTP/1.1
     9 ObjStatus    c 200
     9 ObjResponse  c OK
     9 ObjHeader    c Server: Zope/(Zope 2.10.6-final, python 2.4.5, 
linux2) ZServer/1.1 Plone/3.1.5.1
     9 ObjHeader    c Date: Wed, 28 Jan 2009 10:13:23 GMT
     9 ObjHeader    c Content-Type: text/plain; charset=utf-8
    10 BackendReuse - backend_0
     9 TTL          c 1998529221 RFC 0 1233137603 0 0 0 0
     9 VCL_call     c fetch
     9 TTL          c 1998529221 VCL 86400 1233137604
     9 VCL_return   c pass
     9 Length       c 4
     9 VCL_call     c deliver
     9 VCL_return   c deliver
     9 TxProtocol   c HTTP/1.1
     9 TxStatus     c 200
     9 TxResponse   c OK
     9 TxHeader     c Server: Zope/(Zope 2.10.6-final, python 2.4.5, 
linux2) ZServer/1.1 Plone/3.1.5.1
     9 TxHeader     c Content-Type: text/plain; charset=utf-8
     9 TxHeader     c Content-Length: 4
     9 TxHeader     c X-Varnish-Action: FETCH (pass - not cacheable)
     9 TxHeader     c Date: Wed, 28 Jan 2009 10:13:23 GMT
     9 TxHeader     c X-Varnish: 1998529221
     9 TxHeader     c Age: 0
     9 TxHeader     c Via: 1.1 varnish
     9 TxHeader     c Connection: keep-alive
     9 ReqEnd       c 1998529221 1233137603.757895708 
1233137603.761220932 0.000055552 0.003257036 0.000068188
     0 StatAddr     - 127.0.0.1 0 760 6 6 0 5 6 1970 24


Same backend header, just added a cache-control request key. Succes:


    9 SessionOpen  c 127.0.0.1 41774 127.0.0.1:8000
     9 ReqStart     c 127.0.0.1 41774 1998529224
     9 RxRequest    c GET
     9 RxURL        c /test_varnish
     9 RxProtocol   c HTTP/1.1
     9 RxHeader     c Host: localhost:8000
     9 RxHeader     c User-Agent: Mozilla/5.0 (X11; U; Linux i686; 
en-US; rv:1.9.0.5) Gecko/2008121622 Ubuntu/8.10 (intrepid) Firefox/3.0.5
     9 RxHeader     c Accept: 
text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
     9 RxHeader     c Accept-Language: en-us,en;q=0.5
     9 RxHeader     c Accept-Encoding: gzip,deflate
     9 RxHeader     c Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
     9 RxHeader     c Keep-Alive: 300
     9 RxHeader     c Connection: keep-alive
     9 VCL_call     c recv
     9 VCL_return   c lookup
     9 VCL_call     c hash
     9 VCL_return   c hash
     9 HitPass      c 1998529216
     9 VCL_call     c pass
     9 VCL_return   c pass
     9 Backend      c 10 backend_0 backend_0
    10 TxRequest    - GET
    10 TxURL        - /test_varnish
    10 TxProtocol   - HTTP/1.1
    10 TxHeader     - Host: localhost:8000
    10 TxHeader     - User-Agent: Mozilla/5.0 (X11; U; Linux i686; 
en-US; rv:1.9.0.5) Gecko/2008121622 Ubuntu/8.10 (intrepid) Firefox/3.0.5
    10 TxHeader     - Accept: 
text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    10 TxHeader     - Accept-Language: en-us,en;q=0.5
    10 TxHeader     - Accept-Encoding: gzip,deflate
    10 TxHeader     - Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    10 TxHeader     - X-Varnish: 1998529224
    10 TxHeader     - X-Forwarded-For: 127.0.0.1
    10 RxProtocol   - HTTP/1.1
    10 RxStatus     - 200
    10 RxResponse   - OK
    10 RxHeader     - Server: Zope/(Zope 2.10.6-final, python 2.4.5, 
linux2) ZServer/1.1 Plone/3.1.5.1
    10 RxHeader     - Date: Wed, 28 Jan 2009 10:15:21 GMT
    10 RxHeader     - Content-Length: 4
    10 RxHeader     - Content-Type: text/plain; charset=utf-8
    10 RxHeader     - Cache-Control: max-age=1
     9 ObjProtocol  c HTTP/1.1
     9 ObjStatus    c 200
     9 ObjResponse  c OK
     9 ObjHeader    c Server: Zope/(Zope 2.10.6-final, python 2.4.5, 
linux2) ZServer/1.1 Plone/3.1.5.1
     9 ObjHeader    c Date: Wed, 28 Jan 2009 10:15:21 GMT
     9 ObjHeader    c Content-Type: text/plain; charset=utf-8
     9 ObjHeader    c Cache-Control: max-age=1
    10 BackendReuse - backend_0
     9 TTL          c 1998529224 RFC 1 1233137721 0 0 1 0
     9 VCL_call     c fetch
     9 TTL          c 1998529224 VCL 86400 1233137721
     9 VCL_return   c deliver
     9 Length       c 4
     9 VCL_call     c deliver
     9 VCL_return   c deliver
     9 TxProtocol   c HTTP/1.1
     9 TxStatus     c 200
     9 TxResponse   c OK
     9 TxHeader     c Server: Zope/(Zope 2.10.6-final, python 2.4.5, 
linux2) ZServer/1.1 Plone/3.1.5.1
     9 TxHeader     c Content-Type: text/plain; charset=utf-8
     9 TxHeader     c Cache-Control: max-age=1
     9 TxHeader     c Content-Length: 4
     9 TxHeader     c X-Varnish-Action: FETCH (insert)
     9 TxHeader     c Date: Wed, 28 Jan 2009 10:15:21 GMT
     9 TxHeader     c X-Varnish: 1998529224
     9 TxHeader     c Age: 0
     9 TxHeader     c Via: 1.1 varnish
     9 TxHeader     c Connection: keep-alive
     9 ReqEnd       c 1998529224 1233137721.165423393 
1233137721.168730259 0.000118971 0.003242731 0.000064135

And now the config file:


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


sub vcl_recv {
	set req.grace = 120s;
	set req.backend = backend_0;

}


sub vcl_hit {
	if (req.request == "PURGE") {
		purge_url(req.url);
		error 200 "Purged";
	}

	if (!obj.cacheable) {
         set obj.http.X-Varnish-Action = "PASS (not cacheable - hit)";
		pass;
	}
     set obj.http.X-Varnish-Action = "HIT (deliver - from cache)";
}


sub vcl_fetch {
	set obj.grace = 120s;
         set obj.ttl = 1d;


	if (!obj.cacheable) {
         set obj.http.X-Varnish-Action = "FETCH (pass - not cacheable)";
		pass;
	}
	if (obj.http.Set-Cookie) {
         set obj.http.X-Varnish-Action = "FETCH (pass - response sets 
cookie)";
		pass;
	}
	if (obj.http.Cache-Control ~ "(private|no-cache|no-store)") {
         set obj.http.X-Varnish-Action = "FETCH (pass - cache control 
disallows)";
		pass;
	}
	if (req.http.Authorization && !obj.http.Cache-Control ~ "public") {
         set obj.http.X-Varnish-Action = "FETCH (pass - authorized and 
no public cache control)";
		pass;
	}
	
     set obj.http.X-Varnish-Action = "FETCH (insert)";




/Anton



More information about the varnish-misc mailing list