Caching issue
Shain Miley
SMiley at npr.org
Sun Mar 9 17:57:23 CET 2008
The output from below is a result of 'varnishlog > log.file'. According to the man page if I don't use '-b' or '-c' both are assumed..so I don't know why any of the logging would be missing? Am I missing somthing?
In terms of the 'different Accept-Encoding header ' being set by the other browser..do you mean the 'Vary' header? The reason I ask is because both set Accept-Encoding to 'gzip:deflate' so they are the same there. If it is the result of 'Vary' can I simply remove that header and achive what I am looking for?
I would also like to know if anyone knows how I can better debug the hash that is being created...ie...I would like you know exaclty what information is being used in it's creation, so I can get to a plcae really where only the url is being used as the hash...that way it will match on any machine, from any browser, as long as the url has been cached.
I know that the vcl.conf file that I provided has a lot of redundant info in it...but I was trying to make sure it does a lookup and insert no matter what and I wanted to be sure that no case would be missed...cause it is still not working for me.
Thanks again for taking time to help me,
Shain
________________________________
From: Dag-Erling Smørgrav [mailto:des at linpro.no]
Sent: Sun 3/9/2008 5:49 AM
To: Shain Miley
Cc: Adrian Otto; varnish-dev at projects.linpro.no
Subject: Re: Caching issue
"Shain Miley" <SMiley at npr.org> writes:
> First the cache hit:
>
> 12 SessionOpen c 172.1.1.1 3203
> 12 ReqStart c 172.1.1.1 3203 42332617
> 12 RxRequest c GET
> 12 RxURL c /templates/topics/topic.php?topicId=1006
> 12 RxProtocol c HTTP/1.1
> 12 RxHeader c Host: server11.npr.org:8080
> 12 RxHeader c User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12
> 12 RxHeader c Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=$
> 12 RxHeader c Accept-Language: en-us,en;q=0.5
> 12 RxHeader c Accept-Encoding: gzip,deflate
> 12 RxHeader c Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
> 12 RxHeader c Keep-Alive: 300
> 12 RxHeader c Connection: keep-alive
> 12 RxHeader c Cookie: v1st=7ED84E9096FDA5B; GUID=0003D141E48D07D140F1C40561626364
> 12 RxHeader c If-None-Match: "jpd--899294354.37421"
> 12 VCL_call c recv
> 12 VCL_return c lookup
> 12 VCL_call c hash
> 12 VCL_return c hash
> 12 Hit c 42332555
> 12 VCL_call c hit
> 12 VCL_return c deliver
> 12 Length c 9137
> 12 VCL_call c deliver
> 12 VCL_return c deliver
> 12 TxProtocol c HTTP/1.1
> 12 TxStatus c 200
> 12 TxResponse c OK
> 12 TxHeader c Server: Apache
> 12 TxHeader c X-Powered-By: PHP/5.2.3
> 12 TxHeader c X-Cache: jpcache vv2 - npr-burn
> 12 TxHeader c ETag: "jpd--899294354.37421"
> 12 TxHeader c Cache-Control: max-age=0
> 12 TxHeader c Expires: Sat, 08 Mar 2008 22:41:22 GMT
> 12 TxHeader c Vary: Accept-Encoding
> 12 TxHeader c Content-Encoding: gzip
> 12 TxHeader c Content-Encoding: gzip
> 12 TxHeader c Content-Type: text/html
> 12 TxHeader c Content-Length: 9137
> 12 TxHeader c Date: Sat, 08 Mar 2008 22:43:05 GMT
> 12 TxHeader c X-Varnish: 42332617 42332555
> 12 TxHeader c Age: 102
> 12 TxHeader c Via: 1.1 varnish
> 12 TxHeader c Connection: keep-alive
> 12 ReqEnd c 42332617 1205016185.289316893 1205016185.289417028 0.006116867 0.000038147 0.000061989
Where is the backend traffic? Please use both -b and -c.
> Now the cache miss:
>
> 12 SessionOpen c 172.1.1.1 3211
> 12 ReqStart c 172.1.1.1 3211 42332632
> 12 RxRequest c GET
> 12 RxURL c /templates/topics/topic.php?topicId=1006
> 12 RxProtocol c HTTP/1.1
> 12 RxHeader c Accept: */*
> 12 RxHeader c Accept-Language: en-us
> 12 RxHeader c Accept-Encoding: gzip, deflate
> 12 RxHeader c User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)
> 12 RxHeader c Host: server11.npr.org:8080
> 12 RxHeader c Connection: Keep-Alive
> 12 RxHeader c Cookie: v1st=2E524136463554A; GUID=000748BD59C807AC295102B561626364; LE4=+5SoM6V421+314+4
> 12 VCL_call c recv
> 12 VCL_return c lookup
> 12 VCL_call c hash
> 12 VCL_return c hash
> 12 VCL_call c miss
> 12 VCL_return c fetch
> 12 Length c 455
> 12 VCL_call c deliver
> 12 VCL_return c deliver
> 12 TxProtocol c HTTP/1.1
> 12 TxStatus c 503
> 12 TxResponse c Service Unavailable
> 12 TxHeader c Server: Varnish
> 12 TxHeader c Retry-After: 30
> 12 TxHeader c Content-Type: text/html; charset=utf-8
> 12 TxHeader c Content-Length: 455
> 12 TxHeader c Date: Sat, 08 Mar 2008 22:43:15 GMT
> 12 TxHeader c X-Varnish: 42332632
> 12 TxHeader c Age: 0
> 12 TxHeader c Via: 1.1 varnish
> 12 TxHeader c Connection: keep-alive
> 12 ReqEnd c 42332632 1205016194.493165016 1205016195.508080959 0.005739927 1.014875889 0.000040054
This client sent a different Accept-Encoding header than the first one,
so from Varnish's perspective, these two requests are actually for two
different objects.
> And here is the current vcl.conf:
Is it the same vcl.conf that was in effect when the above requests were
logged?
> #
> # This is a basic VCL configuration file for varnish. See the vcl(7)
> # man page for details on VCL syntax and semantics.
> #
> # $Id: default.vcl 1929 2007-08-29 15:37:59Z des $
> #
>
> # Default backend definition. Set this to point to your content
> # server.
>
> backend default {
> set backend.host = "172.31.2.61"; // use your own backend ip address
> set backend.port = "80"; // use your own backend port
> }
>
> sub vcl_recv {
>
> # Remove the "Cookie:" header from the request.
> remove req.http.Set-Cookie;
> remove req.http.Cache-Control;
>
>
> if (req.request == "GET" && req.url ~ "\.(html|php|gif|jpg|swf|css|js|png|jpg|jpeg|gif|png|tiff|tif|svg|swf|ico|css|js|vsd|doc)$") {
> lookup;
> }
>
> if (req.http.Cache-Control ~ "no-cache") {
> lookup;
> }
> if (req.http.Cache-Control == "max-age=0") {
> lookup;
> }
This is useless, because a) you've already removed that header and b)
Varnish doesn't obey it anyway.
> # Do a "lookup" in the cache. This goes to "vcl_hit", or to
> # "vcl_miss" and then "vcl_fetch"
> lookup;
If you're going to do a lookup anyway, why bother with all of the above?
This will break badly with POST, btw.
> }
>
> # Do the PURGE thing
> sub vcl_hit {
> }
> sub vcl_miss {
> }
>
> sub vcl_fetch {
> if (obj.ttl < 7200s) {
> set obj.ttl = 7200s;
> }
> insert;
>
> if (obj.http.Pragma ~ "no-cache" || obj.http.Cache-Control ~ "no-cache" || obj.http.Cache-Control ~ "max-age=0") {
> insert;
> }
This is useless because a) the "insert" above terminates vcl_fetch and
b) Varnish does not obey Pragma or Cache-Control anyway.
>
> if (obj.ttl < 3600s) {
> set obj.ttl = 3600s;
> }
> insert;
Redundant.
> }
>
> sub vcl_hash {
>
> set req.hash += req.url;
> hash;
> }
Why not host? Why define vcl_hash at all? The default should suffice.
DES
--
Dag-Erling Smørgrav
Senior Software Developer
Linpro AS - www.linpro.no
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-dev/attachments/20080309/20370a6b/attachment-0001.html>
More information about the varnish-dev
mailing list