【发布时间】:2019-01-30 00:40:14
【问题描述】:
响应缓存在 Postman 中运行良好但缓存在其他浏览器中不起作用,并且浏览器中的“Cache-Control”为“public, max-age=60”。 并且每次刷新浏览器都会调用 action 方法。 我的 API 代码:
[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,显示你的 Startup 类配置代码。
标签: c# asp.net-core asp.net-core-webapi asp.net-core-2.2