RFC 7234 Cache
Cache middleware implements HTTP caching (RFC 7234). It's based on the Souin HTTP cache library.
Have a look at the Souin documentation if you need more information.
This is a third-party plugin and isn't included by default. See the "Building RoadRunner with Cache" section for more information.
Features
RFC 7234 compliant HTTP Cache.
REST API to purge the cache and list stored resources.
Built-in support for distributed cache.
Tag-based invalidation.
Partial GraphQL caching.
Configure multiple HTTP verbs to cache (especially for GraphQL).
Built-in timeout.
Building RoadRunner with Cache
As it's based on the Souin HTTP cache library, we can directly use the RoadRunner middleware implementation. We have to set the folder property because this middleware is located in a subdirectory.
[github]
[github.token]
token = "YOUR_GH_TOKEN"
[github.plugins]
# Use the Souin third-party middleware.
cache = { ref = "master", owner = "darkweak", repository = "souin", folder = "/plugins/roadrunner" }
# others ...
[log]
level = "debug"
mode = "development"Available storages: In-memory/Filesystem
nutsdbbadger(default one)
Distributed
etcdolric
More info about customizing RR with your own plugins: link
Configuration
You can set each Souin configuration key under the http.cache key. There is a configuration example below.
http:
# Other HTTP subkeys
cache:
api:
basepath: /httpcache_api
prometheus:
basepath: /anything-for-prometheus-metrics
souin: { }
default_cache:
allowed_http_verbs:
- GET
- POST
- HEAD
cdn:
api_key: XXXX
dynamic: true
hostname: XXXX
network: XXXX
provider: fastly
strategy: soft
headers:
- Authorization
regex:
exclude: '/excluded'
timeout:
backend: 5s
cache: 1ms
ttl: 5s
stale: 10s
log_level: debug
ykeys:
The_First_Test:
headers:
Content-Type: '.+'
The_Second_Test:
url: 'the/second/.+'
surrogate_keys:
The_First_Test:
headers:
Content-Type: '.+'
The_Second_Test:
url: 'the/second/.+'
middleware:
- cache
# Other middlewaresLast updated
Was this helpful?