Tyk v2.2 Documentation Components

  1. Home
  2. Tyk v2.2 Documentation Components
  3. Caching: 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: Disable global cache

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

Cache options form

You must also set:

  1. Caching middleware: To enable the cache middleware.
  2. Cache timeout: To set the timeout for cached requests.
  3. Cache only these status codes: To set which response codes to cache (remember to click the add button).
Step 2: Set the path to cache

Open the endpoint designer and the path you want to cache.

Cache entry on endpoint designer

Step 3: Select the cache plugin

Select the cache plugin option from the drop down.

Plugin dropdown list