我正试图使用query在KONGA中为某些URL配置缓存。
我希望达到的目标是:
应该缓存-> GET /my-awesome-service/get-something?filter-one=this&filter-two=that。
应该以不同的方式缓存-> GET /my-awesome-service/get-something?filter-one=this&filter-two=their。
我面临的是GET /my-awesome-service/get-something正在被缓存,因此返回不同过滤器的错误数据。

发布于 2022-02-23 20:43:34
作为解释在文件中,您需要通过config.vary_query_params将查询参数设置为在缓存键上使用,或者将其保留为未定义以使用所有查询参数。您已经将其设置为timeframe,因此需要添加filter-one和filter-two
Yaml应该是这样的:
plugins:
- name: proxy-cache
config:
cache_control: false
content_type:
- application/json
memory:
dictionary_name: kong_db_cache
request_method:
- GET
response_code:
- 200
strategy: memory
vary_query_params:
- timeframe
- filter-one
- filter-two
enabled: true
protocols:
- grpc
- grpcs
- http
- httpshttps://stackoverflow.com/questions/71202716
复制相似问题