ResponseCache is somewhat a replacement for OutputCache; however, I would like to do server side caching as well as per parameter input.
According to some answers here and here, I should be using IMemoryCache or IDistributedCache to do this. I'm particularly interested in caching on controllers where the parameter is different, previously done in asp.net 4 with OutputCache and VaryByParam like so:
[OutputCache(CacheProfile = "Medium", VaryByParam = "id", Location = OutputCacheLocation.Server)]
public ActionResult Index(long id)
{
///...
}
How would I go about replicating this in asp.net core?
First be sure you are using ASP.NET Core 1.1 or higher.
Then use a code similar to this on your controller method:
Source: https://learn.microsoft.com/en-us/aspnet/core/performance/caching/middleware