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

字號(hào):


    IIS會(huì)按文件地址及參數(shù)將文件緩存到客戶端,以便再次訪問該內(nèi)容時(shí)速度更快。如果要取消這種機(jī)制則需要禁止緩存文件。
    一、編程方式
    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" %>