I have a registered service in Kong and currently trying to set up the proxy-cache plugin.
The plugin itself works fine when cache control is set to false, but when I enable it, the X-Cache-Status header is always Bypass.
The plugin configuration looks like this:
plugins:
- name: proxy-cache
service: echo
config:
response_code
- 200
- 301
- 404
request_method:
- GET
- HEAD
content_type:
- text/plain
- application/json
- application/json; charset=utf-8
- text/plain; charset=utf-8
cache_ttl: 300
strategy: memory
cache_control: true
memory:
dictionary_name: kong_db_cache
And the request looks like this:
curl --location --request GET 'http://localhost:8000/echo' --header 'Cache-Control: public, max-age=20'
I was experimenting with different Cache-Control values, registered also request-transformer plugin and was playing with headers there, but nothing seems to work.
Did anyone encounter this issue before? I'm pretty much stuck here and any kind of suggestion is more than welcome.
You have set the option
cache_control: true
So Kong will respect the Cache-Control behaviors defined in RFC7234
You need to have an cache header into the upstream answer. Or you should set it to false