首页 > 编程技术 > ASP.NET

asp.net(C#)禁止缓存文件不让文件缓存到客户端

发布时间:2021-9-22 10:11

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" %>

标签:[!--infotagslink--]

您可能感兴趣的文章: