You cannot use here if
, because if
, being part of the rewrite module, it is evaluated at an early stage of the request processing before being proxy_pass
called, and the header is returned from the upstream server.
- map
. , map
, , , , . , :
map $upstream_http_cache_control $custom_cache_control {
"~." $upstream_http_cache_control;
default "no-store, no-cache, private";
}
server {
...
location /api {
proxy_pass $apiPath;
proxy_hide_header Cache-Control;
add_header Cache-Control $custom_cache_control;
}
...
}