AnsweredAssumed Answered

Query on usage of Cache Assertion for caching tokens

Question asked by suhas.mv on Jul 26, 2017
Latest reply on Jul 29, 2017 by Arvind.S

I have used the Store Cache and Lookup Cache assertion for Caching the OAuth Token required to invoke a target API. The logic first looks up the cache to check if there is any token exists if not it makes a call to OAuth end point to get the fresh one and stores it in Cache. The logic is in an encapsulated assertion which is used across multiple APIs.
Below is the Cache Configurations

Store to Cache:

  • Cache ID : POC (This is hardcoded and remains same for all)
  • Cache Entry Key : ${request.http.parameter.clientid}  (Mapped from Query Param Client ID and as of now all requests come with same client id)
  • Max Entry Age : 3600 seconds

Lookup from Cache:

  • Cache ID : POC (This is hardcoded and remains same for all)
  • Cache Entry Key : ${request.http.parameter.clientid}
  • Max Acceptable Age : 3600 seconds

 

With the above configuration since Cache ID and Cache Key remains same for all requests , I am expecting the call to OAuth Endpoint should happen every one hour. But sometimes i observed that  even if a fresh entry was made 30 mins back the lookup assertion is not finding and the policy is calling OAuth endpoint. What could be the reason for this behavior?

Policy Flow and Configurations Screenshot:

Outcomes