All Projects → wshirey → Kong Plugin Response Cache

wshirey / Kong Plugin Response Cache

A Kong plugin that will cache responses in redis

Programming Languages

lua
6591 projects

Projects that are alternatives of or similar to Kong Plugin Response Cache

Strapi Middleware Cache
🔌 A cache middleware for https://strapi.io
Stars: ✭ 146 (+121.21%)
Mutual labels:  redis, cache, plugin
Ymate Platform V2
YMP是一个非常简单、易用的轻量级Java应用开发框架,涵盖AOP、IoC、WebMVC、ORM、Validation、Plugin、Serv、Cache等特性,让开发工作像搭积木一样轻松!
Stars: ✭ 106 (+60.61%)
Mutual labels:  redis, cache, plugin
Bloom
🌸 HTTP REST API caching middleware, to be used between load balancers and REST API workers.
Stars: ✭ 553 (+737.88%)
Mutual labels:  redis, cache
Gocache
☔️ A complete Go cache library that brings you multiple ways of managing your caches
Stars: ✭ 775 (+1074.24%)
Mutual labels:  redis, cache
Weixinmpsdk
微信全平台 SDK Senparc.Weixin for C#,支持 .NET Framework 及 .NET Core、.NET 6.0。已支持微信公众号、小程序、小游戏、企业号、企业微信、开放平台、微信支付、JSSDK、微信周边等全平台。 WeChat SDK for C#.
Stars: ✭ 7,098 (+10654.55%)
Mutual labels:  redis, cache
Redis
Vapor provider for RediStack
Stars: ✭ 434 (+557.58%)
Mutual labels:  redis, cache
Aiocache
Asyncio cache manager for redis, memcached and memory
Stars: ✭ 496 (+651.52%)
Mutual labels:  redis, cache
Java Knowledge Mind Map
【🌱🌱Java服务端知识技能图谱】用思维脑图梳理汇总Java服务端知识技能
Stars: ✭ 787 (+1092.42%)
Mutual labels:  redis, cache
Ring
Python cache interface with clean API and built-in memcache & redis + asyncio support.
Stars: ✭ 404 (+512.12%)
Mutual labels:  redis, cache
Spring Boot
spring-boot 项目实践总结
Stars: ✭ 989 (+1398.48%)
Mutual labels:  redis, cache
Exchange Rates
💱 Querying a rate-limited currency exchange API using Redis as a cache
Stars: ✭ 37 (-43.94%)
Mutual labels:  redis, cache
Synchrotron
Caching layer load balancer.
Stars: ✭ 42 (-36.36%)
Mutual labels:  redis, cache
Lada Cache
A Redis based, fully automated and scalable database cache layer for Laravel
Stars: ✭ 424 (+542.42%)
Mutual labels:  redis, cache
Stackexchange.redis.extensions
Stars: ✭ 419 (+534.85%)
Mutual labels:  redis, cache
Laravel Eloquent Query Cache
Adding cache on your Laravel Eloquent queries' results is now a breeze.
Stars: ✭ 529 (+701.52%)
Mutual labels:  redis, cache
Ledge
An RFC compliant and ESI capable HTTP cache for Nginx / OpenResty, backed by Redis
Stars: ✭ 412 (+524.24%)
Mutual labels:  redis, cache
Smartsql
SmartSql = MyBatis in C# + .NET Core+ Cache(Memory | Redis) + R/W Splitting + PropertyChangedTrack +Dynamic Repository + InvokeSync + Diagnostics
Stars: ✭ 775 (+1074.24%)
Mutual labels:  redis, cache
Easycaching
💥 EasyCaching is an open source caching library that contains basic usages and some advanced usages of caching which can help us to handle caching more easier!
Stars: ✭ 1,047 (+1486.36%)
Mutual labels:  redis, cache
Dynomite
A generic dynamo implementation for different k-v storage engines
Stars: ✭ 3,830 (+5703.03%)
Mutual labels:  redis, cache
Miox
Modern infrastructure of complex SPA
Stars: ✭ 374 (+466.67%)
Mutual labels:  cache, plugin

kong-plugin-response-cache

A Kong plugin that will cache JSON responses in redis

How it works

When enabled, this plugin will cache JSON response bodies and headers that match the specified URI list into redis. The duration for the cached response is set in redis and Kong will continue to use the cached response until redis removes it.

The plugin will only cache JSON responses for GET request methods.

Cache Key computation

The cache key will be a concatentation of the following items, in order, each delimited with the : character

  1. The URI path
  2. Query parameter and value (if defined in config.vary_by_query_parameters)
  3. Header name and value (if defined in config.vary_by_headers)

Query strings and headers with multiple values will have those values concatenated and command delimited. See the table below for some examples of requests and their corresponding cache key.

Query strings and headers are concatenated in the cache key in alphabetical order.

request cache key
curl /v1/users/wshirey?is_active /v1/users/wshirey:is_active=true
curl /v1/users/wshirey?foo=bar&is_active /v1/users/wshirey:foo=bar:is_active=true
curl /v1/users/wshirey?foo=bar&foo=baz /v1/users/wshirey:foo=bar,baz
curl -H "X-Custom-ID: 123" /v1/users/wshirey?is_active=true /v1/users/wshirey:is_active=true:x-custom-id=123
curl -H "X-Custom-ID: 123" -H "X-User-ID: 456" /v1/users/wshirey?is_active=true /v1/users/wshirey:is_active=true:x-custom-id=123:x-user-id=456
curl -H "X-Custom-ID: 123" -H "X-Custom-ID: 456" /v1/users/wshirey?is_active=true /v1/users/wshirey:is_active=true:x-custom-id=123,456

Configuration

Similar to the built-in JWT Kong plugin, you can associate the jwt-claims-headers plugin with an api with the following request

curl -X POST http://kong:8001/apis/{api_name_or_id}/plugins \
  --data "name=response-cache" \
  --data "config.cache_policy.uris=/echo,/headers" \
  --data "config.cache_policy.vary_by_query_parameters=" \
  --data "config.cache_policy.vary_by_headers=X-Custom-ID" \
  --data "config.cache_policy.duration_in_seconds=3600" \
  --data "config.redis_host=127.0.0.1" \
form parameter required description
name required The name of the plugin to use, in this case: response-cache
cache_policy.uris required A comma delimited list of URIs that Kong will cache responses. Supports regular expressions.
cache_policy.vary_by_query_parameters optional A comma delimited list of query parameters to use to compute cache key.
cache_policy.vary_by_headers optional A comma delimited list of headers to use to compute cache key.
cache_policy.duration_in_seconds required The amount of time in seconds that a response will be cached in redis (using the redis EXPIRE command). Redis will be responsible from removing cached responses.
redis_host required The hostname or IP address of the redis server.
redis_timeout required The timeout in milliseconds for the redis connection. Defaults to 2000 milliseconds.
redis_port optional The port of the redis server. Defaults to 6379.
redis_password optional The password (if required) to authenticate to the redis server.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].