Skip to content

Instantly share code, notes, and snippets.

@gszr
Created April 17, 2025 16:19
Show Gist options
  • Save gszr/98962ed0ccc2c9503d942f5f31570efa to your computer and use it in GitHub Desktop.
Save gszr/98962ed0ccc2c9503d942f5f31570efa to your computer and use it in GitHub Desktop.
callout-custom-cache-key
{
"name": "request-callout",
"config": {
"callouts": [
{
"name": "callout1",
"request": {
"url": "http://httpbin.org/anything",
"by_lua": "kong.ctx.shared.callouts.callout1.caching.cache_key = kong.request.get_header('cache-key')"
},
"response": {
"body": {
"decode": true
},
"by_lua": "kong.ctx.shared.callouts.callout1.caching.cache_key = kong.request.get_header('cache-key')"
}
}
],
"upstream": {
"headers": {
"forward": false,
"custom": {
"host": "$(kong.request.get_header('host'))",
"status": "$(callouts.callout1.response.status)"
}
}
},
"cache": {
"cache_ttl": 1000,
"strategy": "memory"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment