Tyk v2.2 Documentation Components

HomeTyk v2.2 Documentation ComponentsCaching: Global

Caching: Global

Enabling Caching: 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]

Caching all safe requests

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 many more fine-grained control is required

Enabling Caching: API Dashboard

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

enter image description here

  Step 2: Set the cache options for the global cache

enter image description here

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