Tyk v2.2 Documentation Components

HomeTyk v2.2 Documentation ComponentsCaching: Global

Caching: Global

Enabling caching via the API definition

To enable caching in your API, within your API definition you will need to set the cache_options flags in the main body of the definition:

cache_options: {
    cache_timeout: 10,
    enable_cache: true,
    cache_all_safe_requests: false,
    enable_upstream_cache_control: false,
    cache_response_codes: [200]
}

Note: If you set cache_all_safe_requests to true, then the cache will be global and all inbound requests will be evaluated by the caching middleware. This is great for simple APIs, but for most a finer-grained control is required.

Enabling caching via the Dashboard

Follow these steps to enable caching via the dashboard.

  Step 1: Go to advanced options

Go to the caching options in the API Editor, select the “Advanced Options” tab:

Advanced options tab location

  Step 2: Set the cache options for the global cache

Cache settings

Here you must set:

  1. Enable caching: 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).
  4. Global cache: Enable the global cache.
Was this article helpful to you? Yes No