Caching strategy for rasa action server

I am using “rasa action server” to make a call to external API to fetch the data each time a user does a custom search through the rasa server. Is there any recommended caching strategy that I can leverage with rasa action server to cache the data in memory so that when next time exact same query comes then “rasa action server” can fetch data from the cache rather than making an API call over the network to fetch the data? This will save lots of network bandwidth and will also improve performance?

Further In that case how we will invalidate/refresh the cached data apart from using the TTL? Thanks Rahul Srivastava

you can use the python’s functools lru_cache decorator to cache your object with a max TTL.