您现在的位置: 万盛学电脑网 >> 程序编程 >> 网络编程 >> asp编程 >> 正文

asp.net(C#)怎么禁止缓存文件?

作者:佚名    责任编辑:admin    更新时间:2022-06-22

   IIS会按文件地址及参数将文件缓存到客户端,以便再次访问该内容时速度更快。如果要取消这种机制则需要禁止缓存文件。

  一、编程方式

  Response.Buffer = true;

  Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);

  Response.Cache.SetExpires(DateTime.Now.AddDays(-1));

  Response.Expires = 0;

  Response.CacheControl = "no-cache";

  二、代码方式

  代码如下:

  <%@ OutputCache Duration="1" varybyparam="none" Location="None" %>