Caching with request payload from body

pxzxz1
New Member

In postman, I have the request body message in json format

{ "name": "Mary Jessie", "dob": "2000-02-12", "email": "mary.j@example.com"}

Ideally, I get the response

{"java": "20", "python": "10", "javascript": "15"}

How can I cache based on the values from my request (i.e. Jonathon Zack, 1995-05-15, jon.zack@example.com), the response values for java, python and javascript is changed.

@dino

0 5 916
5 REPLIES 5

Hi

I'm having trouble understanding this part of your question

How can I cache based on the values from my request (i.e. Jonathon Zack, 1995-05-15, jon.zack@example.com), the response values for java, python and javascript is changed.

You want to cache something. Using data in the request to compose the cache key... And then... ?

Hello Dino

Basically it is a simple request and response. I merely want to improve my API performance, thus to cache it so that the requests do not hit the backend server.

This is a really good overview of how Response Caching works in Apigee.

link

Hello Dino

I do not quite get it here. What is a good overview?

Anyway, Apigee docs demonstrate the use of Response Cache. I have some questions.

  1. Why is the Response Cache placed in the Request instead of the Response pipeline?
  2. In what circumstance are we placing the Response Cache in Response pipeline?
  3. In what circumstance are we placing the Response Cache in both Request and Response pipeline?

On top of this, in what circumstance are we using Populate Cache and is it possible to use Populate Cache and Response Cache together?

Sorry; I pasted a link to a YT video and ... for some reason (security?) it does not (did not) appear. The link is there now.

1. Why is the Response Cache placed in the Request instead of the Response pipeline?

If I'm not mistake, the ResponseCache policy should be placed both in the Request and in the Response flow. In the request, it checks the cache and fulfills the request from cache. In the Response, it populates the cache.

2. In what circumstance are we placing the Response Cache in Response pipeline?

All cases. See the video I linked above.

3. In what circumstance are we placing the Response Cache in both Request and Response pipeline?

All cases. See the video I linked above.

On top of this, in what circumstance are we using Populate Cache and is it possible to use Populate Cache and Response Cache together?

Yes. I think of PopulateCache as a cache primitive. You can cache anything, not only responses. So of course you could use it to store and retrieve... things like public keys or credentials for a user, or preferences for a particular client, and so on.