zoukankan      html  css  js  c++  java
  • 通过编程为ASP.NET页面设置缓存

    ASP.NET引入的页面缓存机制,对于大型应用程序开发相当关键。我们可以通过页面声明的方式进行配置

    <%@ OutputCache Duration="10" VaryByParam="none" %>

    还支持在运行时通过编程来设置

    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Cache.SetExpires(DateTime.Now.AddSeconds(10));//这是相对时间,即10秒之后过期
        Response.Cache.SetCacheability(HttpCacheability.Public);
        Response.Cache.SetValidUntilExpires(true);//这句是必须的,否则没有办法实现缓存效果
        Response.Write(DateTime.Now.ToString());
    }
    
  • 相关阅读:
    [转]K/3加密控制规则
    修改Delphi2009的界面风格
    [转]软件版本号讲解: 什么是Alpha, Beta, RC
    百度程序题目连续数问题
    得到正整数a的16进制表示
    四舍五入至某小数位后返回数字串
    返回相同宽度数字型字符串
    百度程序题目连续数问题 另解
    求二进制表示中1的个数
    六支筷子取其二,恰为一双的概率
  • 原文地址:https://www.cnblogs.com/chenxizhang/p/1282719.html
Copyright © 2011-2022 走看看