Caching
Duration --> TIme taken between 2 cache
VarByParam --> give controls id to filter cache
Location --> set where cache file store (server,client,proxy)
important
- VarByParam can be only one contrall.
<%@ OutputCache Duration ="30" VaryByParam="None" %>
Duration --> cach duration in second
<%@ OutputCache Duration ="30" VaryByParam="ddProducts" %>
cache for every single entity in list box
<Asp:DropDownList id ="ddProducts">
<Item> One </Item>
<Item> Two</Item>
<Item> Three</Item>
<Item> Four</Item>
</Asp:DropDownList>
Fragment Caching
Fragments are User contralls
set each and every user contral to cache derective
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="WebUserControl1.ascx.cs" Inherits="SEcond.Cache.WebUserControl1" %>
<%@ OutputCache Duration="30" Shared="true" VaryByParam="None"%>
Cache Data
if(Cache["data"]==null){
Gridview1.Datasource = Cache["Data"] = GetData();
Gridview.DataBind();
}
else{
Gridview1.Datasource = (DataTable)Cache["Data"] ;
Gridview.DataBind();
}
No comments:
Post a Comment