Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

help request: 使用proxy-cache插件如何获取自定义header #11748

Open
23557544 opened this issue Nov 15, 2024 · 0 comments
Open

help request: 使用proxy-cache插件如何获取自定义header #11748

23557544 opened this issue Nov 15, 2024 · 0 comments
Labels
question label for questions asked by users

Comments

@23557544
Copy link

Description

{
  "id": "test-1107-weather-3",
  "uri": "/api/test/weather/cache2disk",
  "plugins": {
    "proxy-rewrite": {
        "uri": "/api/tianqi/tqyb.php"
    },
    "proxy-cache": {
        "cache_strategy": "disk",
        "cache_zone": "disk_cache_default",
        "cache_key":  ["$http_token", "$request_uri", "$request_body", "-cache-id"],
        "cache_ttl": 60,
        "cache_method": ["GET", "POST"],
        "cache_http_status": [200]
    }
  },
  "methods": ["GET"],
  "priority": 10,
  "upstream": {
    "type": "roundrobin",
    "nodes": {
      "cn.xxx.cn:443": 1
    },
    "scheme": "https"
  }
}

定义cache_key时,无法通过$http_token获取请求头中的token值,实际调用时token传入不同的值都会命中缓存。

想问下cache_key如何获取自定义请求头?

Environment

  • APISIX version (run apisix version): 3.11.0
  • Operating system (run uname -a): Linux rancher0 3.10.0-693.el7.x86_64
  • OpenResty / Nginx version (run openresty -V or nginx -V): openresty/1.25.3.2
  • etcd version, if relevant (run curl http://127.0.0.1:9090/v1/server_info): 3.5.16
  • APISIX Dashboard version, if relevant:
  • Plugin runner version, for issues related to plugin runners:
  • LuaRocks version, for installation issues (run luarocks --version):
@dosubot dosubot bot added the question label for questions asked by users label Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question label for questions asked by users
Projects
Status: 📋 Backlog
Development

No branches or pull requests

1 participant