Add / Update Cache-Control headers

Not applicable

Hi there,

I've noticed that the end point that I call from within Apigee returns a private, max-age=0 Cache-Control. What I'd like to do, is change this value and have Apigee pass this on to my client application so that the app can do some caching of it's own.

Does anyone have an example of how to do this (if it's possible). Is it as simple as assigning a message to the response for Cache-Control?

Thanks in advance for any help!

Solved Solved
0 3 1,120
1 ACCEPTED SOLUTION

Not applicable

I think your Response Cache should be fine. They are placed in the expected places.

You should be able to do what is needed without modifying the Cache-Control header by adding a new header that can be set to whatever you would like it to be. If for some reason you can only use the Cache-Control header, it can be set by an Assign Message policy in the proxy.

View solution in original post

3 REPLIES 3

Not applicable

I believe you are not using a Response Cache in your proxy. If you were, the Cache-Control header would be a little different. It's not standard practice to change this header. In the future if you do decide to use an Apigee cache, you may need/want the info set in the header.

With that said, since it is a header and it can be set from within the proxy to whatever value you like. You would use an Assign Message policy to do this. You would want to do this at the end or near the end of your response. Similarly, you could create and set a new header (e.g. X-Cache-Control) and use that as well.

Not applicable

Thanks @Michael Malloy.

I've added a simple response cache on the Proxy PreFlow (after my verify api key step), then added the same policy to the PostFlow (after my transformations, so they are stored in the cache).

Looking at the trace console, I can see that the Cache-Control response header is showing private,max-age=0 - am I doing something wrong (or I've not quite understood what I need to do).

I know I have the response cached on Apigee's side, but I'd like to actually have the response header set so that the client application doesn't need to make a call to Apigee every time.

Not applicable

I think your Response Cache should be fine. They are placed in the expected places.

You should be able to do what is needed without modifying the Cache-Control header by adding a new header that can be set to whatever you would like it to be. If for some reason you can only use the Cache-Control header, it can be set by an Assign Message policy in the proxy.