Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Caching in SAP API MANAGEMENT HCP Trial!

STALANKI
Active Contributor

Hello All,

Did anyone use caching in the trial version? We applied  response cache policy for a scenario and can see it is working partially. It is deriving the CacheKey but  I don't think it is retrieving the value from the cache as the cache source says cache_miss though policy is executed successfully.

Alternatively,We also looked to create custom cache for testing using procedure described here. However We couldn't get it to successfully create a custom local cache using my tenant ID https://apiportal<tenantid>trial.hanatrial.ondemand.com/apiportal/api/1.0/Management.svc/CacheResour.... We are unable to retrieve meta data either from the service. Did any one get this working successfully?


  • SAP Managed Tags:
7 REPLIES 7

Former Member
0 Kudos

Hi Sravya,

are you also getting the CACHE_MISS for the default Response Cache policy?

I just tried this on my Trial account and it worked.

Are you always getting the CACHE_MISS results?

Regards,

Holger.

  • SAP Managed Tags:

STALANKI
Active Contributor
0 Kudos

Hello,

We are getting responsecache.cachesource as CACHE_MISS always? Doesn't it mean it didn't successfully retrieve cache?

Were you able to create a custom local cache using SAP API Management ?

  • SAP Managed Tags:

Former Member
0 Kudos

Hello,

how have you configured the Response Cache? Here is a screenshot of my configuration (sorry, I was somehow not able to copy & paste the text)

Adjust the apikey to what you have in the Verify API Key Policy. Make also sure that you add this policy not only in the incoming, but also outgoing stream of your Preflow.

We are currently preparing a training class on SAP API Management. Once that is done we will have more time to create blogs on SCN again 🙂

Holger.

  • SAP Managed Tags:

ElijahM
Active Contributor
0 Kudos

Sravya, can you give us some details on what you are using to trigger your cache? When misconfigured it will definitely cause a Cache miss. I used code similar to Holger's above (though not the same) on a test proxy, here was the result:

You can see the first result took 5.29 seconds due to its large size, while the second request, a successful cache hit, only took 183ms.

  • SAP Managed Tags:

STALANKI
Active Contributor
0 Kudos

Hello,

Sorry it had taken a while to get back to you, I added 2 preflows for incoming message and outgoing message on the proxy end point., but havent used verify api key. Is it mandatory to use the API key for cache to work? I use the URL as  the Cache Key. It always returns cache_miss for me in the response cache field.

<ResponseCache async="false" continueOnError="false" enabled="true" xmlns="http://www.sap.com/apimgmt">

<CacheKey>

               <KeyFragment ref="request.uri" type="string" ></KeyFragment>

</CacheKey>

    <ExpirySettings>

        <TimeoutInSec ref="">6000</TimeoutInSec>

    </ExpirySettings>

    <SkipCacheLookup>request.header.InvalidateCache = "true"</SkipCacheLookup>

    <SkipCachePopulation></SkipCachePopulation>

</ResponseCache>

  • SAP Managed Tags:

ElijahM
Active Contributor
0 Kudos

Hi Sravya,

In answer to your question, no API key is not mandatory for Caching.

I tested an API Proxy of my own using the code you provided and it hit the cache.

So to troubleshoot:

1) Are you attempting to cache a huge amount of data in a single request? E.g. > 4MB?

2) Do you have the same cache code in both your Response Cache policies (Preflow incoming/outgoing)?

3) Do you have any other policies / options on the API proxy? If so, what is the arrangement of policies?

  • SAP Managed Tags:

STALANKI
Active Contributor
0 Kudos

Hello,

We configured Responsecache using same code on incoming/outgoing response preflow. We tried it on proxy end point and target endpoint but it didn't work.

I don't think we are trying to cache large data. We connected API Target Backend system using ODATA Provisoning.

Cheers,

Sravs

  • SAP Managed Tags: