code_junkie

What's the best way to deal with cache and the browser back button?

Nov 10th, 2011
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));
  2. Response.Cache.SetCacheability(HttpCacheability.Public);
  3. Response.Cache.SetValidUntilExpires(false);
  4. Response.Cache.VaryByParams["Category"] = true;
  5.  
  6. if (Response.Cache.VaryByParams["Category"])
  7. {
  8. //...
  9. }
  10.  
  11. Response.CacheControl = "No-Cache";
  12.  
  13. Response.ClearHeaders();
  14. Response.AppendHeader("Cache-Control", "no-cache"); //HTTP 1.1
  15. Response.AppendHeader("Cache-Control", "private"); // HTTP 1.1
  16. Response.AppendHeader("Cache-Control", "no-store"); // HTTP 1.1
  17. Response.AppendHeader("Cache-Control", "must-revalidate"); // HTTP 1.1
  18. Response.AppendHeader("Cache-Control", "max-stale=0"); // HTTP 1.1
  19. Response.AppendHeader("Cache-Control", "post-check=0"); // HTTP 1.1
  20. Response.AppendHeader("Cache-Control", "pre-check=0"); // HTTP 1.1
  21. Response.AppendHeader("Pragma", "no-cache"); // HTTP 1.1
  22. Response.AppendHeader("Keep-Alive", "timeout=3, max=993"); // HTTP 1.1
  23. Response.AppendHeader("Expires", "Mon, 26 Jul 1997 05:00:00 GMT"); // HTTP 1.1
Add Comment
Please, Sign In to add comment