[master] aa4298c Ignore req.ttl when keeping track of epired objects

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Mon Sep 11 12:35:05 UTC 2017

commit aa4298c951461a3baaafd9d23666c09d3e217fc3
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Mon Sep 11 13:03:52 2017 +0200

    Ignore req.ttl when keeping track of epired objects
    The goal of `req.ttl` is to allow lower requirements for known
    transactions (since this has to be done in VCL) but objects with
    an age higher than `req.ttl` would always be considered expired
    during lookup even if their actual TTL (obj.ttl) is still positive.
    Ignoring `req.ttl` gives a better control over explicit refreshes
    made to optimize latency and greatly reduces the risk of running
    into #1799 (for a subset of use cases).
    Closes #2422

diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c
index 55fa342..2e9baf9 100644
--- a/bin/varnishd/cache/cache_hash.c
+++ b/bin/varnishd/cache/cache_hash.c
@@ -461,7 +461,8 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp,
 			*ocp = oc;
 			return (HSH_HIT);
-		if (oc->t_origin > exp_t_origin) {
+		if (EXP_Ttl(NULL, oc) < req->t_req && /* ignore req.ttl */
+		    oc->t_origin > exp_t_origin) {
 			/* record the newest object */
 			exp_oc = oc;
 			exp_t_origin = oc->t_origin;

More information about the varnish-commit mailing list