Why doesn't Web API come with caching features like MVC actions? Is it because these are HTTP based services so no state in between calls?
I have seen a few open sources like CacheCow and Strathweb, but not sure whom to pick and why? What are the best and standard options for caching with ASP.NET Web API?
This is an extensive article that explains the principal options, and contains links to many more information:
EXPLORING WEB API 2 CACHING
It includes information about:
The poor man's implementation consist in:
check if a value for that key is available in the cache store:
var result = cacheStore.GetValue(keyFromRequest); if (result == null) { result = MyClass.ExpensiveFunctionCall(params); cacheStore.Store(keyFromRequest, result); } return result;
The cache store can be, for example, a database, a memory cache like MemoryCache class, or a Redis server.
The evolution of this idea is to use MVC action filters to make this cache cheking automatic, or to use a fully implemented solution like the aforementioned CacheCow