Commit 4e9fb4b3 authored by Nils Goroll's avatar Nils Goroll

Set default ttl (according to rfc2616 rules) to max-age, do not use Age twice

With 160927b6 t_origin got corrected
by Age, so we already took the age the object had at fetch time into
consideration for all other calculations.

Fixes #1578
parent 0a6e8a6c
......@@ -136,10 +136,7 @@ RFC2616_Ttl(struct busyobj *bo, double now)
else
max_age = strtoul(p, NULL, 0);
if (age > max_age)
expp->ttl = 0;
else
expp->ttl = max_age - age;
expp->ttl = max_age;
break;
}
......
varnishtest "max-age and age"
server s1 {
rxreq
txresp -hdr "Cache-Control: max-age=23" -hdr "Age: 4" -bodylen 40
} -start
varnish v1 -vcl+backend {
sub vcl_backend_response {
set beresp.http.x-ttl = beresp.ttl;
}
sub vcl_hit {
set req.http.x-remaining-ttl = obj.ttl;
}
sub vcl_deliver {
set resp.http.x-remaining-ttl = req.http.x-remaining-ttl;
}
} -start
client c1 {
txreq
rxresp
expect resp.bodylen == 40
expect resp.http.x-ttl == 23.000
expect resp.http.Age == 4
delay 2
txreq
rxresp
expect resp.bodylen == 40
expect resp.http.x-ttl == 23.000
expect resp.http.x-remaining-ttl ~ ^17\.0|^16\.9
delay 2
txreq
rxresp
expect resp.bodylen == 40
expect resp.http.x-ttl == 23.000
expect resp.http.x-remaining-ttl ~ ^15\.0|^14\.9
} -run
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment