Cache large response (more then 512 GB) in Apigee Edge

I have a backend API that returns large JSON response. We implemented response caching in Apigee but it's not caching when response is big. backend API takes sometimes couple of minutes to generate the response but data doesn't change that often.

What are my options to cache such large object to improve performance.

1 9 1,071
9 REPLIES 9

how would streaming help with performance? Consumer app will still have to wait to get the complete response.

Will the data be needed by consumer app all at once? You could send chunks of data in pipe. May be use a node JS app in between to handle that? And if you need to make all the data available to conusmer app, may be paginating it could be a way to go if possible.

One possible way to do it would be to write a small nodejs target that invokes the backend. The nodejs target could then write the response to its local filesystem.

On subsequent calls to the nodejs target, the nodejs logic can read from the local filesystem and respond using that cached data. It will be up to the logic in the nodejs server to determine cache TTL and so on.

You could start with this code. And, if you want to refresh the cache every 10 minutes, add in code that sets up a setTimeout() to run every 10*1000*60 milliseconds, to delete the cache file.

This cache would be local to the nodejs MP. It would not be distributed. If you have multiple MPs each one would maintain its own cache. It sounds like that wouldn't be a problem for you .

You could also make the thing smart enough to respond to cache-control headers, if you wanted to be really savvy.

I think it's still possible to cache large responses using Response Cache policy.

One can create own Cache using the Management API, which allows to set a custom limit on the cache value size. For example:

{
  "name": "MyResponseCache",
  ...
  "skipCacheIfElementSizeInKBExceeds": "1024"
}

And this new Cache can be referred in the Response Cache policy:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ResponseCache ...>
  ...
  <CacheResource>MyResponseCache</CacheResource>
  ...
</ResponseCache>

Hi

Can you please let me know how to create own Cache using the Management API? Do you have a code or document for doing this please.

curl -X POST --header "Content-Type: application/json" -d "{
  "description": "{cache_description}",
  "expirySettings": {
    "expiryDate": {
      "value": "{mm-dd-yyyy}"
    },
    "valuesNull": "{true_false}"
  },
  "overflowToDisk": "{true_false}",
  "skipCacheIfElementSizeInKBExceeds": "{num_elements}"
}" "https://api.enterprise.apigee.com/v1/organizations/org_name/environments/env_name/caches?name=mycache"

just one question . What if I am using on prim APIGEE and not cloud? What will be the link instead of

https://api.enterprise.apigee.com/v1/organizations/org_name/environments/env_name/caches?name=mycach...

Below is the one for onprem, you have to use management server IP and port as below.

http://ms_ip:8080/v1/o/orgname/e/envname/caches?name=mycache