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
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
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.