页面前端:

 

<meta http-equiv='pragma' content='no-cache' />
<meta http-equiv='Cache-Control' content='no-cache, must-revalidate' />
<meta http-equiv='expires' content='-1' />



后台:


 

#region 禁止页面缓存
Response.Buffer = true;
Response.ExpiresAbsolute = System.DateTime.Now.AddSeconds(-1);
Response.Expires = 0;
Response.CacheControl = "no-cache";
Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
Response.Cache.SetNoStore();
#endregion




本 文介绍的这个功能是:禁用页面缓存的解决方法,适用于IE和FireFox浏览器下,在web开发中合理使用缓存可以有效的提高网站的性能,但是在某些场 合下因为缓存的存在会带来很多的问题。例如:因为缓存的存在会造成重复提交数据的问题,验证码图片不能正确显示的问题,等等。这个时候我们就要禁用页面缓 存的功能。 
 
     我们常用的做法是发送一个“no-cache”的指令,但是实际使用过程中我们发现,这个指令对IE是有效的,但是对Firefox却没有效,这是因为, 使用该指令Firefox不缓存HTTPS pages 但是还是会缓存HTTP pages ,这是Firefox的一个BUG,解决的办法很简单,就是使用no-store代替no-cache,同时发送no-store和no-cache指令

     ASP.net中的处理方法,在不需要缓存的页面中添加如下代码

     Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
     Response.Cache.SetNoStore();


相关文章:

  • 2022-12-23
  • 2022-01-12
  • 2021-09-14
  • 2021-11-22
  • 2021-11-21
  • 2022-02-08
  • 2021-07-04
猜你喜欢
  • 2021-10-12
  • 2021-11-29
  • 2021-06-28
  • 2021-12-03
  • 2021-08-26
  • 2021-11-29
  • 2022-01-13
相关资源
相似解决方案