How to use caching in ASP.NET Web API?

后端 未结 4 1174
别那么骄傲
别那么骄傲 2020-12-01 02:41

I am using ASP.NET MVC 4 with WEB API

I have the following action, in the action shown below, my service method makes a db call to DoMagic() method and

4条回答
  •  渐次进展
    2020-12-01 03:07

    [ResponseCache] is now supported in ASP.NET Core

    Features may look identical to [OutputCache] but [ResponseCache] is only for the client side.

    Response caching adds cache-related headers to responses. These headers specify how you want client, proxy and middleware to cache responses.

    https://docs.microsoft.com/en-us/aspnet/core/performance/caching/response

    [ResponseCache(Duration = 3600)]
    [HttpGet]
    public IEnumerable Get()
    {
      return _service.GetAll();
    }
    

提交回复
热议问题