• 通过编程为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());
    }
    
  • 相关阅读:
    [Luogu]小Z的AK计划
    [POI2006]OKR-Periods of Words
    [NOI2014]动物园
    [NOI2009]管道取珠
    [IOI2005]河流
    [国家集训队]Crash的文明世界
    [HDU5382]GCD?LCM!
    [AGC027E]ABBreviate
    [CF]Round510
    [NOIp2005]篝火晚会
  • 原文地址:https://www.cnblogs.com/zcttxs/p/2541763.html
Copyright © 2020-2023  润新知