My relevant setting:
proxy_cache_path /tmp/cache levels=1:2 keys_zone=zone:10m
inactive=24h max_size=1g;
upstream backend {
server xx.xx.xx.xx:xxx;
keepalive 16;
}
server {
...
location ^~ /frontend {
proxy_pass http://backend;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_revalidate on;
proxy_cache zone;
proxy_cache_valid 200 404 2s;
proxy_cache_use_stale updating;
proxy_cache_background_update on;
proxy_cache_lock on;
add_header X-Cache-Status $upstream_cache_status;
}
}
I checked `/tmp/cache` and there are directories automatically generated there.
I tested and yes, the cache works fine. But no `X-Cache-Status` in response headers. I wonder why `$upstream_cache_status` returns an empty value?
proxy_cache_path /tmp/cache levels=1:2 keys_zone=zone:10m
inactive=24h max_size=1g;
upstream backend {
server xx.xx.xx.xx:xxx;
keepalive 16;
}
server {
...
location ^~ /frontend {
proxy_pass http://backend;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_revalidate on;
proxy_cache zone;
proxy_cache_valid 200 404 2s;
proxy_cache_use_stale updating;
proxy_cache_background_update on;
proxy_cache_lock on;
add_header X-Cache-Status $upstream_cache_status;
}
}
I checked `/tmp/cache` and there are directories automatically generated there.
I tested and yes, the cache works fine. But no `X-Cache-Status` in response headers. I wonder why `$upstream_cache_status` returns an empty value?