zoukankan      html  css  js  c++  java
  • ASP.NET2.0缓存技术

    ASP.NET2.0提供如下缓存方式:

    Output Caching

    Fragment Caching

    Data Cache

    SQL Cache

    Cache Configuration

    1. Output Caching:

    当一个网页被频繁访问时,我们可以把把整个网页缓存起来提高效率,当用户在此访问时,被格式化好的HTML被直接送到客户端。

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

    2.  参数缓存:

    根据用户的请求来生成页面,用户的请求只有有限的几种组合,我们根据参数该表缓存内容。

    <%@ OutputCache Duration="120" VaryByParam="state" %>

    <%--<a href="Default.aspx?state=CA"></a>--%>

    3. 硬盘缓存:

    默认情况下Output Cache会缓存到硬盘上,我们可通过修改diskcacheenable的属性设置其是否缓存,还可以通过在web config里配置缓存文件的大小。

    4. 页面碎片缓存:

    页面上部分内容根据请求动态更新,大部分能容被缓存。(如果多个控件需要缓存,可做成一个用户控件)

    <%@OutputCache Duration="120" VaryByControl="ControlID" %>

    clip_image002

    5. Cache Data :

    建议打开硬盘缓存,缓存时间设的稍长一点,因为IO的开销

    DataSet ds=new DataSet();

    ds = Cache["restaurant"];

    if (ds == null)

    {

    ds = resDataSet;

    Cache["restaurant"] = ds;

    }

    6. SQL Dependency

    配置数据库服务器的sql缓存,然后在页面引用

    clip_image004

    7. Cache Configuration (减少重复定义)

    a .web.config定义

    clip_image006

    b. 页面调用

    <%@ OutputCache CacheProfile="CacheFor60Seconds" VaryByParam="name" %>

    扫码关注公众号,了解更多管理,见识,育儿等内容

    作者: 王德水
    出处:http://www.cnblogs.com/cnblogsfans
    版权:本文版权归作者所有,转载需经作者同意。

  • 相关阅读:
    构建单页面应用
    chrome进入控制台时自动进入断点模式的解决方法
    git安装--linux下的安装
    express响应前端ajax请求
    nodejs链接mongodb数据库
    Redis的Java客户端Jedis的八种调用方式(事务、管道、分布式)介绍
    Nginx中如何限制某个IP同一时间段的访问次数
    nodejs && apidoc
    apidoc
    android sdk
  • 原文地址:https://www.cnblogs.com/cnblogsfans/p/992875.html
Copyright © 2011-2022 走看看