We do a lot of REST calls and would like to cache much of those calls. What are our current options? Core does not support Output Caching at the moment, so can we use Response Caching or Distributed Caching for this? If Response Caching, can the IIS reverse proxy in front of Kestrel be used for Response Caching scenarios? Thanks!
ASP.NET Core supports Response Caching.
Output Caching is supported for Razor views by the Cache Helper Tag - but that does not help you for REST calls.
Distributed Caching or InMemory Caching is a good means to store information that is cost intensive to retrieve from the persistence level. This will help you on the service level, but not for the output caching (of course you could do some own middleware, if you want to). The Cache Helper Tag relies on these techniques, too.
So caching output of REST calls comes down to Response Caching. In short this is about how the Cache-Control
header is set in the response. If you choose the ResponseCacheLocation.Any
as Location
in the ResponseCache
annotation of your controller (or the CacheProfile
), the public is used as Cache-Control and reverse proxy are allowed to cache the response as well. But I have not tried, if this is the case in the combination of IIS and Kestrel.
This Blog Post is an interesting read about this topic, too.