Issue description
The proxy cache plugin overrides the Cache Control in the upstream header, even if the plugin is not used in the route.
|
{% if enabled_plugins["proxy-cache"] then %} |
|
### the following configuration is to cache response content from upstream server |
|
|
|
set $upstream_cache_zone off; |
|
set $upstream_cache_key ''; |
|
set $upstream_cache_bypass ''; |
|
set $upstream_no_cache ''; |
|
set $upstream_hdr_expires ''; |
|
set $upstream_hdr_cache_control ''; |
|
|
|
proxy_cache $upstream_cache_zone; |
|
proxy_cache_valid any {% if proxy_cache.cache_ttl then %} {* proxy_cache.cache_ttl *} {% else %} 10s {% end %}; |
|
proxy_cache_min_uses 1; |
|
proxy_cache_methods GET HEAD; |
|
proxy_cache_lock_timeout 5s; |
|
proxy_cache_use_stale off; |
|
proxy_cache_key $upstream_cache_key; |
|
proxy_no_cache $upstream_no_cache; |
|
proxy_cache_bypass $upstream_cache_bypass; |
|
|
|
proxy_hide_header Cache-Control; |
|
proxy_hide_header Expires; |
|
add_header Cache-Control $upstream_hdr_cache_control; |
|
add_header Expires $upstream_hdr_expires; |
|
add_header Apisix-Cache-Status $upstream_cache_status always; |
|
{% end %} |
Disabling the plugin in config.yml solves this problem, but some routes need to enable the plugin. How should I preserve the Cache Control in the upstream header with the proxy cache plugin globally enabled?
Environment
Issue description
The proxy cache plugin overrides the Cache Control in the upstream header, even if the plugin is not used in the route.
apisix/apisix/cli/ngx_tpl.lua
Lines 511 to 536 in e3601e6
Disabling the plugin in
config.ymlsolves this problem, but some routes need to enable the plugin. How should I preserve the Cache Control in the upstream header with the proxy cache plugin globally enabled?Environment