I once realized it using an own class for caching. Not sure if this is the best way though. Then my controller checked if there is a key to return it or to get the data from the service. If you use repository pattern I would let the repository handle it.
What is the best place to Cache the data?
In one of my apps I've to make dozens of call to third party application to get the exact data I want and it also limits the number of api requests I can make.
To overcome the delayed response and api throttle problem, I wish to cache the data.
What is the best place to cache the data - Controller or the Service that fetches the data?
At the moment it feels like it should be cached in the Controller since the data I need to generate unique key is in controller and is not being passed to the service. But wondering if Controller should have knowledge about caching stuff. Or should I add one more layer in between Controller and Service which does the caching and forward the request to Service only when there is Cache miss.
Please or to participate in this conversation.