How does caching work under the hood when we use ResponseCache ,lookup cache policy , populate cache policy . and how to cache a response of an endpoint so that the service callout is not called again using those policies ?
and is it possible to cache the response of a target endpoint? or a whole proxy ?
is the cache accessible to view anyhow from apigee environment rather than this command ????
curl -H "Authorization: Bearer $(gcloud auth print-access-token)" \
https://apigee.googleapis.com/v1/organizations/{projectID}/environments/test/caches
Solved! Go to Solution.
Here is an older example, but it shows the basic approach for response caching (put the ResponseCache policy both in Request flow to respond with cached data if exists, and also in Response flow to cache the response): https://github.com/apigee/api-platform-samples/tree/master/sample-proxies/response-cache
Hi, there are multiple types of cache, and yes, you can cache both the response of a target as well as the whole proxy. The docs have more details and examples: https://cloud.google.com/apigee/docs/api-platform/cache/persistence-tools. In case you have a specific use-case just post here and happy to assist further.
I want to use the ResponseCache to cache the response (payload) of an external endpoint that is called through a service callout.
Is there a way to check this cache if it's working (successfully cached) because the service callout policy is called in the steps of the debugging session anyway ?
Yes you will see it in the Trace, as well as notice that the second / following calls are much faster than going to the target... Happy to share an example if it would be helpful.
can you please provide me with an example , how to set the caching policy properties and where to put it in the steps
Here is an older example, but it shows the basic approach for response caching (put the ResponseCache policy both in Request flow to respond with cached data if exists, and also in Response flow to cache the response): https://github.com/apigee/api-platform-samples/tree/master/sample-proxies/response-cache
And the docs page for the ResponseCache policy has more details and examples on its use: https://cloud.google.com/apigee/docs/api-platform/reference/policies/response-cache-policy
And Here's a screencast walkthrough of Apigee X caching policies!
that's helpful but is there a way to know how does caching works under the hood ?
also is there a way to access these cache variables from within the environment? like to view the list of cached values using an api call or anything ?
@dareenhamdy wrote:
that's helpful but is there a way to know how does caching works under the hood ?
Why do you need to know that? What problem are we solving here?
@dareenhamdy wrote:
is there a way to access these cache variables from within the environment? like to view the list of cached values using an api call or anything ?
No, there is no operation that lists the cache entries. The behavior of the cache is described in the documentation.
Sounds like you're doing some exploration, looking deeply into implementations. I wish you good luck on that effort.
Hi @dareenhamdy, it looks like you've received some really helpful insights from experts, thank you so much @tyayers and @dchiesa1 for your engagement 🙌🏽
If one of these replies resolves your questions, please consider marking it as the accepted solution. This will help others in the community who might have similar questions. Thank you for engaging!