Caching Issue

If requests are made very frequently - with a period under the cache expiry time, then the cached response will be cached again every time and the returned won't be updated ever. 

I have moved the caching in the if block, so it's cached only when the data is updated and when the data is taken from the cache it will not reset the expiry time to 300 seconds.