Caching: Upstream control

Upstream cache control enables you to set whether a response should be cached, and for how long. To enable this, you will need to set enable_cache to and enable_upstream_cache_control to true.

Now you will also need to set on which paths to act, so add these paths to the cache list in the extended path section of your API version.

Tyk will evaluate the response headers sent from your application for these paths and based on the data in the response activate and set the cache values.

The two response headers that Tyk looks for are:

x-tyk-cache-action-set: If Tyk finds this header set to 1, the request will be cached.

x-tyk-cache-action-set-ttl: If Tyk finds this header, it will override the TTL of the cached response, otherwise it will default to cache_options.cache_timeout.

Utilising this method gives the most control as it will also only cache requests based on their method, so if you only want OPTIONS requests to be cached, then only that method/URL combination will be cached, ignoring other methods for the same path.

Configuration via the Dashboard

Under the advanced settings, ensure that Enable upstream control is activated and the global cache is deactivated, then follow the steps for per-path caching.

Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

You can adjust all of your cookie settings by navigating the tabs on the left hand side.