Set global cache for API

Hello Team!

Can I configure for an API that the cache is global?

Currently we use OUTH (client credentials) and for each api - client it generates a cache.

For some services I want to set global cache.

Can be done?

thanks greetings.

1 Like

hi @juanjo_granada
You can find the global Caching options on our docs page here:

Thanks, G.

Hi @Gregor, thank you for the fast response.
It is just what I have done, I show you an example:
“cache_options”: {
“cache_timeout”: 60,
“enable_cache”: true,
"cache_all_safe_requests": true,
“enable_upstream_cache_control”: false,
“cache_by_headers”: [],
“cache_response_codes”: [
200
]
}

But it doesn’t work, I use two OAUTH clients for the same API and create two caches.
How can configure to have only one global cache?.

If you look at the Date parameter of the header it generates two different dates for two different OAUTH clients, so the global cache does not seem to work.

Thanks, JG

POC (http://httpbin:80/):

{

    "name": "uxxi.sta.apipr.prueba1.v1",

    "slug": "uxxi.sta.apipr.prueba1.v1",

    "api_id": "uxxi.sta.apipr.prueba1.v1",

    "org_id": "UXXI",

    "version_data": {

        "not_versioned": true,

        "versions": {

            "Default": {

                "name": "Default",

                "use_extended_paths": true              

            }

        }

    },

    "use_oauth2": true,

    "oauth_meta": {

        "allowed_access_types": [

            "client_credentials"

        ],

        "allowed_authorize_types": [

            "token"

        ],

        "auth_login_redirect": "http://example.com"

    },

"auth": {

    "use_param": false,

    "param_name": "",

    "use_cookie": false,

    "cookie_name": "",

    "auth_header_name": "Authorization",

    "use_certificate": false

},

    "cache_options": {

        "cache_timeout": 60,

        "enable_cache": true,

        "cache_all_safe_requests": true,

        "enable_upstream_cache_control": false,

        "cache_by_headers": [],

        "cache_response_codes": [

            200

        ]

    },

    

    "proxy": {

        "check_host_against_uptime_tests": true,

        "listen_path": "/uxxi/sta/apipr/prueba1/v1/",

        "target_url": "http://httpbin:80/",

        "strip_listen_path": true

    },

    "active": true

}

Hi @Gregor
There is no response to this thread.
I appreciate if it is possible that you attend to his answer.
Thank you very much

Hi! Sorry for delay!

Indeed default cache is per token.
There is way to make it global, but it require creating second internal Api using Looping

Idea here is that oauth api you have will be without caching and it’s target will be our second api, smth like: tyk://api2 (since we use “looping” technique, there is no any network overhead). Your second internal api will be keyless and will have caching turned on, e.g global cache. Hope it makes sense!

1 Like

@leon: Thank you, let’s try them