Tyk v2.2 Documentation Components

HomeTyk v2.2 Documentation ComponentsCaching: Upstream control

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:

  1. x-tyk-cache-action-set: 1 If Tyk finds this header, Tyk will cache the request
  2. 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.

In the Dashboard

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

Was this article helpful to you? Yes No