Caching cloud function response

We are using cloud functions for returning aggregated data which internally is done using mongo aggregation queries. Looking into adding a simple caching mechanism to store response from cloud function in redis with function name and request params as key for the same.

  1. Can’t find a direct hook in cloud function for parse cache similar to parse queries.Is there something for cloud functions or am I better off just using a vanila node cache client
  2. Would appreciate any recommendation/issues with this key-value strategy

Where do you want to cache? In the client side or in the server side?

server side. the blog wont let me post <20 char lol

There isn’t any hook for functions. So I see two options:

  • In the beginning of the functions, verify the cache, and, at the end, save in the cache. You can try to override the default definition of the Parse.Cloud.define() function to write this logic a single time.
  • Use some service like Cloudflare or CloudFront and setup it to do the cache for you.
1 Like