[4.1] ad92c56 Ignore req.ttl when keeping track of epired objects

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Mon Sep 11 13:00:07 UTC 2017


commit ad92c565109e4850c5ee375160b231a40c6272a4
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).
    
    Refs #2422

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


More information about the varnish-commit mailing list