I have a strange nginx caching behavior. There are 2 responses. The first one had stopped caching when I updated server from 1.6 to 1.8.1, another one is caching like before. The first one (broken) has following response headers:
Allow →GET, HEAD, OPTIONS
Connection →keep-alive
Content-Encoding →gzip
Content-Language →ru
Content-Type →application/json
Date →Tue, 15 Mar 2016 07:31:53 GMT
Server →nginx/1.8.1
Transfer-Encoding →chunked
Vary →Accept,Accept-Language,Cookie,Accept-Encoding
X-Frame-Options →SAMEORIGIN
Another response (which works as I expect) has following headers:
Connection →keep-alive
Content-Encoding →gzip
Content-Language →ru
Content-Type →application/json
Date →Tue, 15 Mar 2016 07:32:40 GMT
Server →nginx/1.8.1
Transfer-Encoding →chunked
Vary →Accept-Language,Cookie,Accept-Encoding
X-Frame-Options →SAMEORIGIN
There are no cookies or Accept header in the first case, but only
proxy_ignore_headers Vary
saved the situation. It works well with it. Looks like some magic. But what was wrong, what am I missing? Below are the current settings:
proxy_pass http://localhost:7050;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
limit_req zone=banka burst=5 nodelay;
proxy_cache cache;
proxy_cache_valid 5m;
proxy_ignore_headers Vary;