Cache endpoint level cache is not functional

Hi, we are trying to set up endpoint level cache and see that it is not function as expected. However if we set cache_all_safe_requests to true, Global API level cache is working, but it caches all endpoints.

Here is the API definition

apiVersion: tyk.tyk.io/v1alpha1
kind: ApiDefinition
metadata:
name: test
spec:
name: test
version_data:
not_versioned: false
versions:
Default:
use_extended_paths: true
extended_paths:
cache:
- /api/product/typea/v1
- /api/product/typbeb/v1
cache_options:
cache_all_safe_requests: false
cache_timeout: 86400
# cache_timeout: 10
cache_response_codes:
- 200
enable_cache: true

Which is overriden from base for diff env

the base api definition is

apiVersion: tyk.tyk.io/v1alpha1
kind: ApiDefinition
metadata:
name: test
labels:
template: “true”
spec:
contextRef:
name: operator-context-dev
namespace: stg
name: test
protocol: http
use_keyless: true
proxy:
target_url: http://placeholder
response_processors:

  • name: header_injector
    version_data:
    not_versioned: false
    default_version: Default
    versions:
    Default:
    name: Default
    use_extended_paths: true
    global_response_headers:
    Strict-Transport-Security: max-age=31536000
    CORS:
    enable: true
    allowed_origins:
    • “*”
      allowed_methods:
    • “GET”
    • “OPTIONS”
    • “POST”
    • “PATCH”
    • “DELETE”
    • “PUT”
      allowed_headers: [““]
      exposed_headers: [”
      ”]
      allow_credentials: false
      max_age: 24
      options_passthrough: false
      debug: true
      cache_options:

cache_all_safe_requests: false

cache_by_headers:

cache_timeout: 60
cache_response_codes:
  - 200
enable_cache: true

@pavankarajgi Hello and welcome to the community :partying_face:

Have you had a look at our documentation on endpoint cahcing? It mentions the used of the advance_cache_config field?

If the problem persists, then could you share the REST API response of GET /tyk/apis/{api_id} for review.

Let us know if this helps. Apologies for the delay.

Hi Olu, thank you for your repoonse. As you have mentioned, made use of advance cache config to achieve endpoint based caching. It works as expected. Thanks…!

2 Likes