8 ASP.NET Core
缓存
客户端响应缓存
使用 cache-control 响应报文头, 实现客户端缓存这一请求的结果一段时间, cache-control: max-age=20 表示在浏览器中缓存 20 秒
// 设置缓存 20 秒
[ResponseCache(Duration = 20)]
[HttpGet}
public int GetNum()
{
return 10;
}
使用 cache-control 响应报文头, 实现客户端缓存这一请求的结果一段时间, cache-control: max-age=20 表示在浏览器中缓存 20 秒
// 设置缓存 20 秒
[ResponseCache(Duration = 20)]
[HttpGet}
public int GetNum()
{
return 10;
}