HttpContext.Response.Cache equivalent in .NET Core?
You could directly set the corresponding response headers to the desired values:
public class NoCacheAttribute : ActionFilterAttribute{ public override void OnResultExecuting(ResultExecutingContext filterContext) { filterContext.HttpContext.Response.Headers["Cache-Control"] = "no-cache, no-store, must-revalidate"; filterContext.HttpContext.Response.Headers["Expires"] = "-1"; filterContext.HttpContext.Response.Headers["Pragma"] = "no-cache"; base.OnResultExecuting(filterContext); }}
You can control it with build-on attribute:
[ResponseCache (NoStore = true, Location = ResponseCacheLocation.None)]