zoukankan      html  css  js  c++  java
  • ASP.NET2.0瞎记____数据缓存

    页面缓存
    <%@ OutputCache Duration="30" VaryByParam="none" %>
    带参数的
    <%@ OutputCache Duration="60"  VaryByParam="temp"%>

    页面有temp这个Get参数的时候,就会把当前页面产生的HTML代码产生一个缓存,不同的temp参数会产生不同的缓存

    用户控件缓存和页面缓存大体一样

    Substitution WEB控件

    Substitution 控件用在配置为需要进行缓存的 ASP.NET 网页上。Substitution 控件允许您在页上创建一些区域,这些区域可以用动态方式进行更新,然后集成到缓存页。
    Substitution 控件调用的方法必须符合下面的标准:

    • 此方法被定义为静态方法(在 Visual Basic 中为共享方法)。
    • 此方法接受 HttpContext 类型的参数。
    • 此方法返回 String 类型的值。(MSND)

    如果页加上缓存可以用 Substitution 控件 来实现不被缓存的方法,也就是程序的部分的缓存
    .aspx
    <%@ OutputCache Duration="30" VaryByParam="none" %>
    .. 
    .. 
    .. 
    <asp:Substitution ID="Substitution1" runat="server"  MethodName="GetDate"/>
    .. 
    .aspx.cs
       protected void Page_Load(object sender, EventArgs e)
        
    {
            Response.Write(System.DateTime.Now.ToString());

        }

        
    public static string GetDate(HttpContext Content)
        
    {
            
    return System.DateTime.Now.ToString();
        }

    当数据量大的时候,最好通过硬盘缓存一起使用
    catch["catchDate"= DataSet
    .aspx
    <%@ OutputCache Duration="30" VaryByParam="none"  DiskCacheable="true"%>
    web.config里可以配置硬盘缓存大小
    <system.web>
    <caching>
     
    <outputCache><diskCache enabled="true",maxSizePerApp="2(M)"></outputCache>
    </caching>
    <system.web>
  • 相关阅读:
    the selected directory is not a TomEE home
    java 获取当前年份 月份,当月第一天和最后一天
    java jwt工具类,生成和解析token
    Thymeleaf嵌套循环,每次循环显示固定数量
    oracle 非正常关机 错误1033解决办法
    webService简单记录
    好用的json工具
    org.apache.ws.commons.schema.XmlSchemaForm.getValue()Ljava/lang/String;
    webservice获取ip地址
    JSP(一)
  • 原文地址:https://www.cnblogs.com/mmmhhhlll/p/446327.html
Copyright © 2011-2022 走看看