Commit 14ce4804 authored by Reza Naghibi's avatar Reza Naghibi Committed by Pål Hermunn Johansen

Make sure Age is always less than max-age

By rounding Age down, we make sure Age < max-age while the object
is fresh. Otherwise, we can prematurely get Age == max-age and Varnish
will calculate that as a 0s TTL and create a pass scenario.

Conflicts:
	bin/varnishd/cache/cache_req_fsm.c
parent 09ce321d
......@@ -154,7 +154,7 @@ cnt_deliver(struct worker *wrk, struct req *req)
* age. Truncate to zero in that case).
*/
http_PrintfHeader(req->resp, "Age: %.0f",
fmax(0., req->t_prev - req->objcore->exp.t_origin));
floor(fmax(0., req->t_prev - req->objcore->exp.t_origin));
http_SetHeader(req->resp, "Via: 1.1 varnish-v4");
......
varnishtest "Check that Age is always less than max-age while not stale"
server s1 {
rxreq
expect req.url == "/"
txresp -hdr "Cache-control: max-age=2"
} -start
varnish v1 -vcl+backend { } -start
client c1 {
txreq -url "/"
rxresp
expect resp.status == 200
expect resp.http.Age == 0
delay 0.8
txreq -url "/"
rxresp
expect resp.status == 200
expect resp.http.Age == 0
delay 1.0
txreq -url "/"
rxresp
expect resp.status == 200
expect resp.http.Age == 1
} -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