Proxy_cache not working anymore in 1.8

Hi

We use nginx as proxy_cache and identified a different somehow weird
behaviour compared to 1.6.:

In some situations we get a MISS or EXPIRED in 1.8, where with the same
config, same resource and same origin, we got a HIT in 1.6.

The weird thing is, it does never change to a HIT even after several
requests to the same resource! We always get MISSED or EXPIRED. We do
not use proxy_cache_min_uses.

Below I show you some configs, nothing really fancy. Does anyone use 1.8
for proxy_cache?

1.6: rpm spec and sources:
https://github.com/swisstxt/rpm-pcache/commit/cabe5f83b8c02ae8ce74543f669c9b0c0fc41f03

1.8: rpm spec and sources:
https://github.com/swisstxt/rpm-pcache/commit/da336fd143e21500e445df4a5ece0af7f8a9448b

Response from ORIGIN:

Cache-Control: public, max-age=49
Content-Type: application/json; charset=utf-8
Content-MD5: O+EP2TJJZQZr61/mhkVqdA==
Expires: Mon, 01 Jun 2015 11:09:05 GMT
Last-Modified: Mon, 01 Jun 2015 11:08:05 GMT
Vary: *
access-control-allow-origin: *
Date: Mon, 01 Jun 2015 11:08:15 GMT
Content-Length: 743

nginx respone in 1.6.:
Server: nginx
Date: Mon, 01 Jun 2015 11:20:59 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 728
Connection: keep-alive
Cache-Control: public, max-age=60
Content-MD5: aMGk4M7K6qzjnOIvVfy6fg==
Expires: Mon, 01 Jun 2015 11:21:48 GMT
Last-Modified: Mon, 01 Jun 2015 11:20:48 GMT
Vary: *
access-control-allow-origin: *
X-Node: cache.example.com
X-Cached: HIT
200 OK

nginx response in 1.8.:
Server: nginx
Date: Mon, 01 Jun 2015 11:23:41 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 728
Connection: keep-alive
Cache-Control: public, max-age=56
Content-MD5: aMGk4M7K6qzjnOIvVfy6fg==
Expires: Mon, 01 Jun 2015 11:24:38 GMT
Last-Modified: Mon, 01 Jun 2015 11:23:38 GMT
Vary: *
access-control-allow-origin: *
X-Node: cache.example.com
X-Cached: MISS
200 OK

2nd nginx response in 1.8.:
Server: nginx
Date: Mon, 01 Jun 2015 11:24:53 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 728
Connection: keep-alive
Cache-Control: public, max-age=57
Content-MD5: aMGk4M7K6qzjnOIvVfy6fg==
Expires: Mon, 01 Jun 2015 11:25:50 GMT
Last-Modified: Mon, 01 Jun 2015 11:24:50 GMT
Vary: *
access-control-allow-origin: *
X-Node: cache.example.com
X-Cached: MISS
200 OK

#file nginx.conf:

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
add_header X-Node $hostname;
add_header X-Cached $upstream_cache_status;

changed to fake IPs

resolver 1.2.3.4 1.2.3.5;

log_format main '$remote_addr - $remote_user [$time_local] $request

'“$status” $body_bytes_sent “$http_referer” ’
‘“$http_user_agent” “$http_x_forwarded_for”’;

access_log /var/log/nginx/access.log main;

server_tokens off;
sendfile on;
keepalive_timeout 10s;
tcp_nopush on;
tcp_nodelay on;

proxy_temp_path /srv/www/temp;

proxy_connect_timeout 10s;
proxy_send_timeout 20s;
proxy_read_timeout 20s;
send_timeout 30s;

charset utf-8;
charset_types application/javascript text/css application/atom+xml;

ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

}

#file foobar.example.com.conf:

upstream foobar-origins {
server lb.foobar.example.com;
}

proxy_cache_path /srv/www/cache/foobar.example.com levels=1:2
keys_zone=foobar:10m inactive=2d max_size=1g;

server {
listen 1.1.104.140:80;
server_name foobar.example.com;

access_log /srv/www/log/foobar.example.com/access.log combined;
error_log /srv/www/log/foobar.example.com/error.log;
access_log /srv/www/log/foobar.example.com/pcache.log pcache_json
buffer=16k;

set $volume_key “foobar”;
access_log /srv/www/log/global_pcache_volume.log volume-key;

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_cache_key “$scheme$host$request_uri”;

proxy_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;

location / {
proxy_cache foobar;
proxy_cache_valid 200 206 301 302 5m;
proxy_cache_valid any 10s;
proxy_cache_lock on;
proxy_cache_use_stale error timeout invalid_header updating http_500
http_502 http_503 http_504 http_403 http_404;
proxy_pass http://foobar-origins;
}

}

Any hints?

Yours
René

Today Jun 1, 2015 at 13:28 Rene Moser wrote:

Hi

We use nginx as proxy_cache and identified a different somehow weird
behaviour compared to 1.6.:

In some situations we get a MISS or EXPIRED in 1.8, where with the same
config, same resource and same origin, we got a HIT in 1.6.

Content-Length: 743
Module ngx_http_proxy_module
If the header includes the “Vary” field with the special value “*”,
such
a response will not be cached (1.7.7). If the header includes the
“Vary”
field with another value, such a response will be cached taking into
account the corresponding request header fields (1.7.7).


WNGS-RIPE

Hi

On 01.06.2015 13:51, Oleksandr V. Typlyns’kyi wrote:

Vary: *
Module ngx_http_proxy_module
If the header includes the “Vary” field with the special value “*”, such
a response will not be cached (1.7.7). If the header includes the “Vary”
field with another value, such a response will be cached taking into
account the corresponding request header fields (1.7.7).

I can confirm this was the “issue”, thank you for this helpful and fast
response!

Yours
Ren