nginx 1.8 not caching reverse proxy [FIX]

Just updated our loadbalancers to nginx-1.8. As we need some custom modules, I grabbed the SRPM from here and modified the spec file to fit our needs. As usual, compiling was a breeze and I updated the staging server. Everything was fine, except that nginx was not caching some of our backends responses. A quick check with the live nginx servers showed that this problem was introduced by the update. So I checked which calls did not get cached and had a closer look at the response headers from the backends and it turned out, that the vary-http header was the only difference. Headers like:

< HTTP/1.1 200 OK
< Content-Length: 22333
< Content-Language: *
< Content-Type: application/xml; charset=UTF-8
< Expires: Wed, 09 Sep 2015 13:15:38 GMT
< ETag: "8eb73cc447dc29e1c3620c747ba89b95"
< Cache-Control: max-age=600, max-age=600
< Date: Wed, 09 Sep 2015 13:05:38 GMT
< Accept-Ranges: bytes
< Vary: Accept-Charset, Accept-Encoding, Accept-Language, Accept

would cause the response to not be cached but headers like:

< HTTP/1.1 200 OK
< Content-Length: 22333
< Content-Language: *
< Content-Type: application/xml; charset=UTF-8
< Expires: Wed, 09 Sep 2015 13:15:38 GMT
< ETag: "8eb73cc447dc29e1c3620c747ba89b95"
< Cache-Control: max-age=600, max-age=600
< Date: Wed, 09 Sep 2015 13:05:38 GMT
< Accept-Ranges: bytes
< Vary: Accept

would not cause this problem. So I suspected that the length of the vary header might be the problem. Wrote a simple tcp server to check and – well what should I say: the answer was 42. That is the maximum length of the vary header in this nginx release.
A quick look at the source provided more insight. In src/http/ngx_http_cache.h, line 28:

#define NGX_HTTP_CACHE_VARY_LEN      42

So i patched this to 250, recompiled and the problem was fixed.
02.03.2017: UPDATE
This was recently fixed. See here.

Dieser Beitrag wurde unter /dev/administration veröffentlicht. Setze ein Lesezeichen auf den Permalink.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.