-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Closed
Labels
good first issueGood for newcomersGood for newcomers
Description
Issue description
The proxy cache plugin overrides the Cache Control in the upstream header, even if the plugin is not used in the route.
Lines 511 to 536 in e3601e6
{% 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
- apisix version: 2.2
- OS: Linux 7cc563f53b08 4.19.121-linuxkit change: added doc of how to load plugin. #1 SMP Tue Dec 1 17:50:32 UTC 2020 x86_64 Linux
- OpenResty / Nginx version: nginx version: openresty/1.19.3.1
Metadata
Metadata
Assignees
Labels
good first issueGood for newcomersGood for newcomers