giammin

Asp.net DisableBrowserCache

Mar 20th, 2012
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.28 KB | None | 0 0
  1.         private void DisableBrowserCache()
  2.         {
  3.             //back browser
  4.             Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1));
  5.             Response.Cache.SetValidUntilExpires(false);
  6.             Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
  7.             Response.Cache.SetCacheability(HttpCacheability.NoCache);
  8.             Response.Cache.SetNoStore();
  9.  
  10.             //back browser and refresh
  11.             //Response.ClearHeaders();
  12.             //Response.AppendHeader("Cache-Control", "no-cache"); //HTTP 1.1
  13.             //Response.AppendHeader("Cache-Control", "private"); // HTTP 1.1
  14.             //Response.AppendHeader("Cache-Control", "no-store"); // HTTP 1.1
  15.             //Response.AppendHeader("Cache-Control", "must-revalidate"); // HTTP 1.1
  16.             //Response.AppendHeader("Cache-Control", "max-stale=0"); // HTTP 1.1
  17.             //Response.AppendHeader("Cache-Control", "post-check=0"); // HTTP 1.1
  18.             //Response.AppendHeader("Cache-Control", "pre-check=0"); // HTTP 1.1
  19.             //Response.AppendHeader("Pragma", "no-cache"); // HTTP 1.1
  20.             //Response.AppendHeader("Keep-Alive", "timeout=3, max=993"); // HTTP 1.1
  21.             //Response.AppendHeader("Expires", "Mon, 26 Jul 1997 05:00:00 GMT"); // HTTP 1.1}
  22.         }
Advertisement
Add Comment
Please, Sign In to add comment