zoukankan      html  css  js  c++  java
  • asp.net 页面不缓存

     Response.Expires = 0;
                Response.Buffer = true;
                Response.ExpiresAbsolute = DateTime.Now.AddSeconds(-1);
                Response.AddHeader("pragma", "no-cache");
                Response.CacheControl = "no-cache";
                //Response.Write("{\"NowTime\":\"" + DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss", System.Globalization.DateTimeFormatInfo.InvariantInfo) +
     "\"}");
     context.Response.ClearContent();
     context.Response.ContentType = ("text/xml;charset=GB2312"); // 这里必须要设置,否则客户端接收不到这里写好的xml文件
    context.Response.Cache.SetCacheability(HttpCacheability.NoCache); //没有缓存

     string result = CreateXmlResult(keyWord);

     context.Response.Write(result); 
    context.Response.Flush(); 
     context.Response.End();
    
    
    
    
    写在前台的
        <meta http-equiv="Expires" CONTENT="0"> 
        <meta http-equiv="Cache-Control" CONTENT="no-cache"> 
        <meta http-equiv="Pragma" CONTENT="no-cache">
        <%Response.Buffer = true;
          Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);
          Response.Cache.SetExpires(DateTime.Now.AddDays(-1));
          Response.Expires = 0;
          Response.CacheControl = "no-cache";
          Response.Cache.SetNoStore(); %>
    
    
    
    最简单数据缓存
     HttpContext.Current.Cache.Insert("SimplifyEsfURL", dsURL, null, DateTime.Now.AddMinutes(1), TimeSpan.Zero);
     HttpContext.Current.Cache.Get("SimplifyEsfURL")
    
    
    文件依赖缓存
    Cache.CacheManager.Set(cacheName, dt, new System.Web.Caching.CacheDependency(xmlPath));
  • 相关阅读:
    python之定时器Timer
    (转载)Python一篇学会多线程
    docker速记
    IP地址简单入门
    pycharm快捷键及一些常用设置(转载)
    python系列1_travel
    Fluter基础巩固之Dart语言详解<三>
    Fluter基础巩固之Dart语言详解<二>
    Fluter基础巩固之Dart语言详解<一>
    Java精通并发-Condition编程模式详解与分析
  • 原文地址:https://www.cnblogs.com/zhangji/p/1798213.html
Copyright © 2011-2022 走看看