一、浏览器缓存

服务器如果返回 cache-control:max-age=60,则表示服务器通知浏览器端可以缓存这个内容60秒

//缓存3秒
[ResponseCache(Duration = 3)]
[HttpGet]
public DateTime get()
{
return DateTime.Now;
}

 浏览器端可以选择禁用缓存。

 

二、服务端缓存

app.UseCors();
//在UseCors后,MapControllers前app.UseResponseCaching();

app.MapControllers();