0

The response cache works well in Postman But cache does not work in other browsers and "Cache-Control" in browser is " public, max-age=60" . And every time refresh browser the action method is called . my Api Code :

[HttpGet]
    [ResponseCache(Duration =60)]

    public IActionResult GetAllCustomer()
        {           
        Request.HttpContext.Response.Headers.Add("X-Total-Custumer", _h_Plus_SportsContext.Customer.Count().ToString());

        return new ObjectResult(_customerService.GetAllCustomer())
        {
            StatusCode = (int)HttpStatusCode.OK
        };
    }
Jb_Dda
  • 41
  • 8

1 Answers1

0

You should provide more context, but Chrome and possible other browser are sending by default Cache-control header with a value of 0 (this happens even if Chrome Dev Tools has Disable cache unchecked):

Cache control 0

A workaround is to follow a link to your link to be tested or use Back button as indicated here.

Alexei - check Codidact
  • 22,016
  • 16
  • 145
  • 164
  • Can you please take a look at the question I posted? https://stackoverflow.com/questions/72755972/netcore-responsecache-does-not-work-for-some-routes – Offir Jun 25 '22 at 17:58