Tyk v2.2 Documentation Components

HomeTyk v2.2 Documentation ComponentsCaching: Per-path

Caching: Per-path

To cache only specific endpoints, within the version data under the extended_paths section, you will need to define the paths to cache in the cache list:

extended_paths: {
    ignored: [],
    white_list: [],
    black_list: [],
    cache: [
    transform: [],
    transform_headers: []

Now Tyk will only cache the /widget, /badger, and /fish endpoints. Tyk will only cache safe requests, so GET, OPTIONS and HEAD requests. For many this will suffice with regards to caching requests, however in some cases you may wish to have full control over when to cache and be reactive about the time to live of the cached response.

You will still need to set the timeout, and the response codes to validate in the cache configuration section.

Setting up a per-path cache in the dashboard

Step 1. Ensure that the global cache is disabled (“Cache all safe requests is not checked)

enter image description here

You must also set:

  1. To enable the cache middleare
  2. To set the timeout for cached requests
  3. To set which response codes to cache (remember to click the “add” button)
Step 2. Open the endpoint designer and the path you want to cache:

enter image description here

Step 3. Select the cache plugin option from the drop down

enter image description here

Was this article helpful to you? Yes No