location /images {
proxy_cache XXX;
proxy_cache_valid 200 302 72h;
proxy_cache_valid 301 7d;
proxy_cache_min_uses 1;
add_header nx-type "XXX";
add_header nx-cache "$upstream_cache_status";
add_header nx-key $host$uri$is_args$args;
proxy_cache_key $host$uri$is_args$args;
proxy_ignore_headers X-Accel-Expires Expires Cache-Control Set-Cookie Vary;
#proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504;
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;
proxy_set_header Host $host;
#proxy_set_header Connection "";
proxy_connect_timeout 300;
#proxy_buffers 2048 10k;
#proxy_http_version 1.1;
#chunked_transfer_encoding off;
proxy_ignore_client_abort on;
types {}
default_type image/jpeg;
proxy_pass http://127.0.0.1:9000/dmm/;
}
一直无法正常缓存, cache 的状态一直MISS.
添加
proxy_buffering on;
帮助中的一句提示:
Make sure proxy_buffering stays on - that will bypass the cache if turned off, and make sure your key space is large because you'll throw 500s for everything if it runs out (I figured it would evict a key if it ran out of space, and what was a wrong assumption
网友评论