API Connect

 View Only

 Invoke Policy Caching & Datapower

Seif Abdelsamea's profile image
Seif Abdelsamea posted Tue December 24, 2024 03:26 AM

Dears,

In IBM API connect, I'm using caching in the invoke policy to cache a token coming from the backend. I noticed a unexpected behaviour, which is when I call the api (that caches the token during execution) from my local machine, caching works perfectly, However. when trying the same cURL ( hitting the same datapower node to avoid any load balancer issues)  Caching doesn't work. Also when the consumers use my api the backend of the token block me because of many tokens consumed.

Appreciate your support regarding this matter.

version: 2.2.0
                    title: 'GetToken: invoke'
                    backend-type: detect
                    header-control:
                      type: blocklist
                      values: []
                    parameter-control:
                      type: allowlist
                      values: []
                    timeout: 60
                    verb: GET
                    chunked-uploads: true
                    persistent-connection: true
                    http-version: HTTP/1.1
                    cache-response: time-to-live
                    cache-putpost-response: true
                    cache-ttl: 1209600
                    websocket-upgrade: false
                    target-url: $(token-url)
                    cache-key: UpdateMeeting

Regards,

Steve Linn's profile image
Steve Linn

Hi Seif,
The only thing that should cause caching to not work would be the presence of an Authorization request header, or perhaps the presence of a Cache-Control header with a no-cache value.  If this isn't the case I would suggest you open a PMR.

Best Regards,
Steve Linn

Seif Abdelsamea's profile image
Seif Abdelsamea

Hi Seif,
The only thing that should cause caching to not work would be the presence of an Authorization request header, or perhaps the presence of a Cache-Control header with a no-cache value.  If this isn't the case I would suggest you open a PMR.

Best Regards,
Steve Linn

Dear @Steve Linn,

Thank you very much for your prompt assistance which helped me a lot.

After following your directions I do still have 3 other questions.

1. what can cause that caching to work only perfectly on 1 node in data power and the other 2 nodes only cache for a couple of minutes ( TTL set to 14 days, works on node 1 only)

2. cache-pupost-reponse : true helps me cache only in POST requests, however, most of my APIs ( tokens) are GET, how do I enable caching in GET  APIS?

3. Is blocking Authorization and Cache-Control headers ( by adding them to the blocklist in the invoke policy) enough to prevent caching issues?

Appreciate your support.

Regards,

Seif