How to Invalidate a cache entry that was populated by ResponseCache?

How can I invalidate a cache entry that was inserted with the ResponseCache policy?

I have a response cache that is populated for a URL.

In a different API, that gets invoked after initially filling the cache, the resource that is being cached gets updated. Therefore I also want to invalidate the ResponseCache element for that resource.

How can I do that using the InvalidateCache policy? What scope? What key?

I have seen this question , but I don't want to resort to nodejs and apigee-access for this purpose.

Solved Solved
1 5 1,098
1 ACCEPTED SOLUTION

Not applicable

Hi @Dino,

Standard InvalidateCachePolicy can be used after successful update as part of the second API call. Ensure "scope" variable has been set as "Global" so that same cache key can be constructed.

Rather than invalidating cache value, new value may be updated as part of the cache itself.

Cheers,

Rajesh Doda

View solution in original post

5 REPLIES 5

adas
Participant V

Can't you have an endpoint in the first proxy specifically for the cache invalidation, so that when the resource gets updated in proxy 2 and you need to invalidate the cache, you can make a service callout to the proxy 1 endpoint (using proxy chaining/path chaining) to invalidate the cache. I am not sure I understood your scenario entirely, so if you can elaborate a bit more it would be helpful.

Ahhh, what key do I use?

Do you have these proxies setup somewhere that I can use ? I am not able to visualize this entirely.

@Dino

Not sure understood the question properly. But if second proxy is updating the resource then we can clear the cache for that resource in second proxy itself using InvalidateCache policy

Not applicable

Hi @Dino,

Standard InvalidateCachePolicy can be used after successful update as part of the second API call. Ensure "scope" variable has been set as "Global" so that same cache key can be constructed.

Rather than invalidating cache value, new value may be updated as part of the cache itself.

Cheers,

Rajesh Doda