[Varnish] #1578: Problem in the TTL calculation, if have age and max-age

Varnish varnish-bugs at varnish-cache.org
Fri Aug 22 17:13:56 CEST 2014


#1578: Problem in the TTL calculation, if have age and max-age
-------------------+----------------------
 Reporter:  xcir   |       Type:  defect
   Status:  new    |   Priority:  normal
Milestone:         |  Component:  varnishd
  Version:  4.0.1  |   Severity:  normal
 Keywords:         |
-------------------+----------------------
 Hi, I found a event that TTL is shorter, if have max-age and age.

 https://github.com/varnish/Varnish-
 Cache/blob/16e07984abbeac8fa5a014175efd164e8e90d1a8/bin/varnishd/cache/cache_rfc2616.c#L103

 Age affect the t_origin.

 But, age affect again, if have max-age.

 https://github.com/varnish/Varnish-
 Cache/blob/16e07984abbeac8fa5a014175efd164e8e90d1a8/bin/varnishd/cache/cache_rfc2616.c#L142

 Age will double effect.

 ---sample(php)
 {{{
 <?php header('Cache-Control: max-age=10'); ?>
 <?php header('Age: 2'); ?>
 <?php echo date('H:i:s '); ?>
 }}}

 ---vcl
 {{{
 sub vcl_backend_response {
   set beresp.http.x-ttl = beresp.ttl;
   set beresp.grace      = 0s;
 }
 sub vcl_hit{
   std.log("obj.ttl:"+obj.ttl);
 }
 }}}

 ---Before
 {{{
 root at varnish4a:~/git/Varnish-Cache# /tmp/varnish4/bin/varnishncsa -F"%t
 %{Varnish:hitmiss}x [Age]:%{age}o [obj.ttl]:%{VCL_Log:obj.ttl}x
 [beresp.ttl]:%{x-ttl}o"
 [22/Aug/2014:23:27:23 +0900] miss [Age]:2 [obj.ttl]: [beresp.ttl]:8.000
 //Remaining TTL 6 seconds.
 [22/Aug/2014:23:27:24 +0900] hit [Age]:3 [obj.ttl]:5.289
 [beresp.ttl]:8.000
 [22/Aug/2014:23:27:29 +0900] hit [Age]:7 [obj.ttl]:0.522
 [beresp.ttl]:8.000
 [22/Aug/2014:23:27:29 +0900] hit [Age]:8 [obj.ttl]:0.235
 [beresp.ttl]:8.000
 [22/Aug/2014:23:27:29 +0900] miss [Age]:2 [obj.ttl]: [beresp.ttl]:8.000
 [22/Aug/2014:23:27:30 +0900] hit [Age]:2 [obj.ttl]:5.690
 [beresp.ttl]:8.000
 [22/Aug/2014:23:27:30 +0900] hit [Age]:3 [obj.ttl]:5.315
 [beresp.ttl]:8.000
 [22/Aug/2014:23:27:34 +0900] hit [Age]:7 [obj.ttl]:1.259
 [beresp.ttl]:8.000
 [22/Aug/2014:23:27:34 +0900] hit [Age]:7 [obj.ttl]:0.899
 [beresp.ttl]:8.000
 [22/Aug/2014:23:27:35 +0900] hit [Age]:7 [obj.ttl]:0.522
 [beresp.ttl]:8.000
 [22/Aug/2014:23:27:35 +0900] hit [Age]:8 [obj.ttl]:0.147
 [beresp.ttl]:8.000
 [22/Aug/2014:23:27:35 +0900] miss [Age]:2 [obj.ttl]: [beresp.ttl]:8.000
 [22/Aug/2014:23:27:36 +0900] hit [Age]:2 [obj.ttl]:5.642
 [beresp.ttl]:8.000
 [22/Aug/2014:23:27:36 +0900] hit [Age]:3 [obj.ttl]:5.274
 [beresp.ttl]:8.000
 [22/Aug/2014:23:27:36 +0900] hit [Age]:3 [obj.ttl]:4.961
 [beresp.ttl]:8.000
 [22/Aug/2014:23:27:37 +0900] hit [Age]:3 [obj.ttl]:4.625
 [beresp.ttl]:8.000
 }}}

 --After(apply patch)
 {{{
 [22/Aug/2014:23:32:41 +0900] miss [Age]:2 [obj.ttl]: [beresp.ttl]:10.000
 //Remaining TTL 8 seconds.
 [22/Aug/2014:23:32:42 +0900] hit [Age]:3 [obj.ttl]:7.355
 [beresp.ttl]:10.000
 [22/Aug/2014:23:32:42 +0900] hit [Age]:3 [obj.ttl]:6.690
 [beresp.ttl]:10.000
 [22/Aug/2014:23:32:43 +0900] hit [Age]:4 [obj.ttl]:6.224
 [beresp.ttl]:10.000
 [22/Aug/2014:23:32:43 +0900] hit [Age]:4 [obj.ttl]:5.754
 [beresp.ttl]:10.000
 [22/Aug/2014:23:32:47 +0900] hit [Age]:8 [obj.ttl]:2.020
 [beresp.ttl]:10.000
 [22/Aug/2014:23:32:47 +0900] hit [Age]:8 [obj.ttl]:1.610
 [beresp.ttl]:10.000
 [22/Aug/2014:23:32:48 +0900] hit [Age]:9 [obj.ttl]:1.171
 [beresp.ttl]:10.000
 [22/Aug/2014:23:32:48 +0900] hit [Age]:9 [obj.ttl]:0.794
 [beresp.ttl]:10.000
 [22/Aug/2014:23:32:49 +0900] hit [Age]:10 [obj.ttl]:0.362
 [beresp.ttl]:10.000
 [22/Aug/2014:23:32:49 +0900] miss [Age]:2 [obj.ttl]: [beresp.ttl]:10.000
 [22/Aug/2014:23:32:49 +0900] hit [Age]:2 [obj.ttl]:7.641
 [beresp.ttl]:10.000
 [22/Aug/2014:23:32:50 +0900] hit [Age]:3 [obj.ttl]:7.234
 [beresp.ttl]:10.000
 [22/Aug/2014:23:32:50 +0900] hit [Age]:3 [obj.ttl]:6.881
 [beresp.ttl]:10.000
 [22/Aug/2014:23:32:51 +0900] hit [Age]:4 [obj.ttl]:6.474
 [beresp.ttl]:10.000
 [22/Aug/2014:23:32:51 +0900] hit [Age]:4 [obj.ttl]:6.074
 [beresp.ttl]:10.000
 [22/Aug/2014:23:32:55 +0900] hit [Age]:8 [obj.ttl]:2.105
 [beresp.ttl]:10.000
 [22/Aug/2014:23:32:55 +0900] hit [Age]:8 [obj.ttl]:1.705
 [beresp.ttl]:10.000
 [22/Aug/2014:23:32:56 +0900] hit [Age]:9 [obj.ttl]:1.337
 [beresp.ttl]:10.000
 [22/Aug/2014:23:32:56 +0900] hit [Age]:9 [obj.ttl]:0.888
 [beresp.ttl]:10.000
 [22/Aug/2014:23:32:57 +0900] hit [Age]:9 [obj.ttl]:0.534
 [beresp.ttl]:10.000
 [22/Aug/2014:23:32:57 +0900] hit [Age]:10 [obj.ttl]:0.138
 [beresp.ttl]:10.000
 [22/Aug/2014:23:32:57 +0900] miss [Age]:2 [obj.ttl]: [beresp.ttl]:10.000
 [22/Aug/2014:23:32:58 +0900] hit [Age]:2 [obj.ttl]:7.587
 [beresp.ttl]:10.000
 [22/Aug/2014:23:32:58 +0900] hit [Age]:3 [obj.ttl]:7.194
 [beresp.ttl]:10.000
 [22/Aug/2014:23:32:59 +0900] hit [Age]:3 [obj.ttl]:6.763
 [beresp.ttl]:10.000
 }}}

-- 
Ticket URL: <https://www.varnish-cache.org/trac/ticket/1578>
Varnish <https://varnish-cache.org/>
The Varnish HTTP Accelerator



More information about the varnish-bugs mailing list