I've created a cache policy in front of my proxy. I set TimeoutInSec and everything is work. I'm just wondering if is possible to setup a "return stale while recreating" behaviour.
Basically, if a request hit my proxy and the cache version has expired, I want the proxy to return to the client the stale cache version and refresh the cached version by calling my backend.
Thanks
Hmm, ok that's an interesting scenario.
It's not possible, straightaway. If I correctly understand what you want, then it is possible to do it, with 2 caches.
The first cache will have a TTL of... whatever you want it to be. Let's say, TTL of 60 minutes. The second cache will have a TTL of ... infinite. Then, here's how the flow works.
Does this make sense?
The asynchronous step to retrieve data from the backend may need to be wrapped in a self-standing proxy, or possibly a separate ProxyEndpoint. You can use a JS fire-and-forget step to invoke that proxy over HTTP and not wait for the response. This allows you to respond to the client without waiting for the backend response.
Putting the cache population logic into a separate proxy means the Scope of the Cached item must not be "proxy". It should be "Global" or "Application" , depending on whether the cache-maintenance logic is contained in a distinct proxy or a distinct proxyendpoint.
Thanks ! I need few days to setup and test everything. I'll keep you posted.
ok, let me know!
I'll tell you we will need some time. We are still investigating all APIgee potentials to define the best for us. I've jsut discovered that cache can be purged on demand http://docs.apigee.com/management/apis/post/organizations/%7Borg_name%7D/environments/%7Benv_name%7D... that's another alternative for us. I'll keep you posted.
Yes, the caching is quite powerful in Apigee. OK, I am interested to learn what you finally decide. Of course if you have more questions, you can ask here.
I tried to do it as described, but failed on setting up conditions and how to respond with cached result using LookupCache without calling target service. Could you provide any examples of how to setup specific flows and policies?
Hi Sergei
please ask a new question, rather than posting a question as a comment to an answer on a 1-year old thread.
Ask a new question: