News New Look, Same Vision: KrakenD’s Website Redesign

You are viewing a previous version of KrakenD Enterprise Edition (v1.3), go to the latest version

Document updated on May 2, 2021

Caching backend responses

Sometimes you might want to reuse a previous response of a backend instead of asking for the same information over the network again. In this cases, it is possible to enable in-memory caching for the desired backend responses.

This caching technique applies to traffic between KrakenD and your microservices endpoints only and is not a caching system for the end-user endpoints. To enable the cache, you only need to add in the configuration file the httpcache middleware.

When enabled all connections for the configured backend are cached in-memory for the amount of time retrieved from the Cache-Control header of the response.

Performance notice!
This option can increase the load and memory consumption heavily as KrakenD needs to keep in memory all the returned data during the expiration period. Use wisely!

If you enable this module, you are required to be very aware of the response sizes, caching times and the hit-rate of the calls.

Enable the caching of the backend services in the backend section of your krakend.json with the middleware:

"github.com/devopsfaith/krakend-httpcache": {}

The middleware does not require additional configuration other than the simple inclusion.

See an example:

...
"backend": [
{
  "url_pattern": "/",
  "host": ["http://my-service.tld"],
  "extra_config": {
    "github.com/devopsfaith/krakend-httpcache": {}
  }
}
]

Scarf

Unresolved issues?

The documentation is only a piece of the help you can get! Whether you are looking for Open Source or Enterprise support, see more support channels that can help you.

See all support channels