KiMoGiGi 技术文集

不在乎选择什么,而在乎坚持多久……

IT博客 首页 联系 聚合 管理
  185 Posts :: 14 Stories :: 48 Comments :: 0 Trackbacks

 //CleanClientCache  清除客户端缓存
    #region
    protected void CleanClientCache()
    {
        StringBuilder str = new StringBuilder();
        str.Append("<meta http-equiv=\"Expires\" content=\"0\">");
        str.Append("<meta http-equiv=\"Cache-Control\" content=\"no-cache\">");
        str.Append("<meta http-equiv=\"Pragma\" content=\"no-cache\">");
        HttpContext.Current.Response.Write(str.ToString());
    }
    #endregion

    //CleanServerCache  清除服务器端缓存
    #region
    protected void CleanServerCache()
    {
        HttpContext.Current.Response.Buffer = true;
        HttpContext.Current.Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);
        HttpContext.Current.Response.Cache.SetExpires(DateTime.Now.AddDays(-1));
        HttpContext.Current.Response.Expires = 0;
        HttpContext.Current.Response.CacheControl = "no-cache";
        HttpContext.Current.Response.Cache.SetNoStore();
    }
    #endregion

posted on 2006-10-15 11:10 KiMoGiGi 阅读(359) 评论(0)  编辑 收藏 引用 所属分类: Web小技巧
只有注册用户登录后才能发表评论。