From: Willy Tarreau Date: Thu, 21 Dec 2017 15:08:09 +0000 (+0100) Subject: BUG/MINOR: http: do not ignore cache-control: public X-Git-Tag: v1.9-dev1~554 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=12b32f212f4c7457eeae37edb06dd0a06995fce1;p=thirdparty%2Fhaproxy.git BUG/MINOR: http: do not ignore cache-control: public In check_response_for_cacheability(), we don't check the cache-control flags if the response is already supposed not to be cacheable. This was introduced very early when cache-control:public was not checked, and it basically results in this last one not being able to properly mark the response as cacheable if it uses a status code which is non-cacheable by default. Till now the impact is very limited as it doesn't check that cookies set on non-default status codes are not cacheable, and it prevents the cache from caching such responses. Let's fix this by doing two things : - remove the test for !TX_CACHEABLE in the aforementionned function - however take care of 1xx status codes here (which used to be implicitly dealt with by the test above) and remove the explicit check for 101 in the caller This fix must be backported to 1.8. --- diff --git a/src/proto_http.c b/src/proto_http.c index afeb96ee52..42e253aeb9 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -5833,7 +5833,7 @@ int http_process_res_common(struct stream *s, struct channel *rep, int an_bit, s /* * Check for cache-control or pragma headers if required. */ - if (((s->be->options & PR_O_CHK_CACHE) || (s->be->ck_opts & PR_CK_NOC)) && txn->status != 101) + if ((s->be->options & PR_O_CHK_CACHE) || (s->be->ck_opts & PR_CK_NOC)) check_response_for_cacheability(s, rep); /* @@ -7690,8 +7690,11 @@ void check_response_for_cacheability(struct stream *s, struct channel *rtr) char *cur_ptr, *cur_end, *cur_next; int cur_idx; - if (!(txn->flags & TX_CACHEABLE)) + if (txn->status < 200) { + /* do not try to cache interim responses! */ + txn->flags &= ~TX_CACHEABLE & ~TX_CACHE_COOK; return; + } /* Iterate through the headers. * we start with the start line.