I am trying to cache upstream response when upstream response with 200 and 401, not caching other response status code.
Also want to make sure caching zone is separate for both cache.
With my below configuration caching is not happening.
Configuration which I tried :
upstream.conf :
proxy_cache_path /apps_01/apigw/tmp/nginx_200_cache_stage levels=1:2 inactive=15m keys_zone=200_cache_stage:10m;
proxy_cache_path /apps_01/apigw/tmp/nginx_401_cache_stage levels=1:2 inactive=15m keys_zone=401_cache_stage:10m;
map $upstream_http_status $cache_zone {
200 200_cache_stage;
401 401_cache_stage;
}
route.conf :
proxy_pass_request_headers off;
proxy_cache $cache_zone;
proxy_cache_valid 200 15m;
proxy_cache_valid 401 15m;
proxy_cache_methods POST;
proxy_cache_key $request_body;
Can anyone help me with this ?