From: Willy Tarreau Date: Thu, 21 Dec 2017 14:59:17 +0000 (+0100) Subject: BUG/MINOR: cache: do not force the TX_CACHEABLE flag before checking cacheability X-Git-Tag: v1.9-dev1~552 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=faf2909f9f73a43b8db9a9ef884f64a0113ac1c9;p=thirdparty%2Fhaproxy.git BUG/MINOR: cache: do not force the TX_CACHEABLE flag before checking cacheability The cache used to set this flag before calling check_response_for_cacheability() due to the way the flags were previously set (too late), but this is a bad idea as it loses the information of the implicit caching rules related to the method and the status code. Let's only rely on what was determined during the request and response parsing instead and not change it. This fix must be backported to 1.8, and it requires that the following patches are also merged : - MINOR: http: adjust the list of supposedly cacheable methods - MINOR: http: update the list of cacheable status codes as per RFC7231 - MINOR: http: start to compute the transaction's cacheability from the request - BUG/MINOR: http: do not ignore cache-control: public --- diff --git a/src/cache.c b/src/cache.c index cdfd43d570..459c2e8bf5 100644 --- a/src/cache.c +++ b/src/cache.c @@ -431,11 +431,7 @@ enum act_return http_action_store_cache(struct act_rule *rule, struct proxy *px, if (http_find_header2("Vary", 4, txn->rsp.chn->buf->p, &txn->hdr_idx, &ctx)) goto out; - /* we need to put this flag before using check_response_for_cacheability */ - txn->flags |= TX_CACHEABLE; - - if (txn->status != 101) - check_response_for_cacheability(s, &s->res); + check_response_for_cacheability(s, &s->res); if (!(txn->flags & TX_CACHEABLE)) goto out;