Disable browser cache for entire ASP.NET website

前端 未结 8 1675
既然无缘
既然无缘 2020-11-22 03:20

I am looking for a method to disable the browser cache for an entire ASP.NET MVC Website

I found the following method:

Response.Cach         


        
8条回答
  •  面向向阳花
    2020-11-22 04:14

    HttpContext.Current.Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1));
    HttpContext.Current.Response.Cache.SetValidUntilExpires(false);
    HttpContext.Current.Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
    HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
    HttpContext.Current.Response.Cache.SetNoStore();
    

    All requests get routed through default.aspx first - so assuming you can just pop in code behind there.

提交回复
热议问题