在ASPX代码中,希望该网页不要被缓冲区保存,有两个代码都可以生效

一种长的:

      Response.Buffer = true;
      Response.ExpiresAbsolute = System.DateTime.Now.AddDays(-1);
      Response.Expires = -1;
      Response.CacheControl = "no-cache";
      Response.AddHeader("Pragma", "No-Cache");


一种短的:

      Response.Cache.SetCacheability(HttpCacheability.NoCache);

 

另外,在ASHX代码中,我也用:

      context.Response.Cache.SetExpires(DateTime.Now.AddHours(-1));

但在ASPX中就没效果了。

在客户端,JavaScript中也可以使用URL加上时间,或随机数来避免使用缓冲区内容。

先记这些,以后有时间再去对比它们。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-05
  • 2022-12-23
  • 2022-02-17
  • 2022-01-01
  • 2021-07-20
猜你喜欢
  • 2021-11-27
  • 2021-12-22
  • 2022-12-23
  • 2021-10-28
  • 2021-05-16
  • 2021-12-22
相关资源
相似解决方案