Search code examples
.netasp.net-web-apiasp.net-corehttp-caching

Output caching of API controllers in ASP.NET 5


Am I correct that in ASP.NET 5 ResponseCacheAttribute has replaced OutputCacheAttribute used in previous ASP.NET MVC releases? Can it be used to cache responses of API controllers? If not, what do Microsoft offer instead? I tried two free solution for WebAPI2 but was not impressed at all.


Solution

  • Yes, you will be able to use the ResponseCacheAttribute.

    Because there is no difference between a Web Api Controller and an MVC Controller, you will be able to use the same attributes for both. This will apply whether it is the ResponseCacheAttribute, AuthorizeAttribute, RouteAttribute, or any others.