VisualBuilder
  Home > Aspnet > Tutorials > CACHING IN ASP.NET APPLICATION - ASP.NET Tutorial
Tell a friend
Link to us
Total Members
      Members: 84661
     
Sitemap Forum Chat
Home
ASP.NET Tutorial Home
1 . Introduction
2 . Static and Dynamic Web sites
3 . Dynamic Web sites
4 . What is ASP
5 . How ASP Works
6 . What is ASP.NET
7 . What is a Framework?
8 . ASP.NET Versions
9 . The .NET Framework architecture
10 . Important Terminologies
11 . Why Use ASP.NET
12 . Setting up ASP.NET
13 . Installation of .NET Framework 2.0
14 . Installing the Software Development Kit (SDK)
15 . Configuring IIS for ASP.NET 2.0
16 . Developing your First ASP.NET Page
17 . Understanding the ASP.NET Code
18 . Next Steps
19 . Asp.Net
20 . DataList
21 . Validation Controls
22 . ExecuteNonQuery
23 . ADO.NET
24 . Using Parameters with Queries
25 . EXECUTE SCALER: Retrieving Single Database Record
26 . Improving Database Performance Using Stored Procedure
27 . Example for XML Handling Using ASP. Net.
28 . CACHING IN ASP.NET APPLICATION
29 . GridView Control
30 . Master-Detail Relationship: Using DATALIST and REPEATER Control
31 . Data Binding – WebControls [REPEATER CONTROL]
32 . Session Management in Asp.Net
 
Aspnet Group Home
Aspnet Discussion (10)
Aspnet Members (2382)
Aspnet Resources
Aspnet Source Code (388)
Aspnet Articles (1)
Aspnet Blogs
Aspnet Jobs
Aspnet Components (201)
Aspnet Books
Aspnet Websites (21)
Aspnet News (105)
Aspnet Q & A (114)
- Aspnet Ask Question
- Aspnet Questions
- Aspnet Unanswered Questions
 
GROUPS
.NET
ASP.NET
.NET
C#
ASP
Visual Basic
Java
Java
JSP
EJB
Other
Delphi
C++
Ajax
UML
JavaScript
PHP
Web Design
Web Hosting
SQL Server
Oracle
Project Management
More Groups

 
LEARNING CENTER
TUTORIALS
.NET
.NET Tutorial
ASP Tutorial
ASP.NET Database Tutorial
ASP.NET Development Tips
ASP.Net Security,Internationalisation And Deployment
ASP.NET Server Controls Tips
ASP.NET Tutorial
C Sharp Tutorial
Web Development
Flex Tutorial
HTML Tutorial
Learn AJAX Tutorial
PHP Tutorial
Software Development
Database Tutorial
SQL Tutorial
UML Tutorial
Java
Ant Tutorial
EJB 3 Tutorial
Hibernate Tutorial
Java Tutorial
Java Web Component Tutorial
Java XML Tutorial
JDBC Tutorial
JDK1.5 Tutorial
JSF Tutorial
JSP And J2EE Design Tutorial
JSP Tutorial
Spring Tutorial
Struts Tutorial

RESOURCES
Q & A (434 )
Source Code (3275 )
Articles (11 )
Components (1595 )
News (888 )
Websites (1207 )

SUBMISSIONS
Submit Article
Submit Website
Submit News
Submit Source Code
Submit Component

COMMUNITY
Members Directory
Discussion Forum
Chat

SITE
About Us
Sitemap
Search
Contact Us
Link To Us
Feedback
Tell a Friend
Partners
Advertise

Aspnet Tutorial
 CACHING IN ASP.NET APPLICATION
  << Prev: Example for XML Handling Using ASP. Net. Next: GridView Control >>

Caching:


 


Caching dramatically improve the performance of your web site. Instead of executing a page each time the page is requested, you can cache the output of the page and send the cached copy to satisfy the browser requests.


 


There are 3 type of caching:



  1. Paged Output caching

  2. Fragment caching

  3. Data caching


 


Page Output caching :


 


To improve the performance of the web site the page are cached and next time when the browser make the request of the same page the request is handled by the cache module and the page response is through the cached page.


 


The following code will enable output caching:


 


<%@ OutputCache Duration=”60varyByParam=”noneVaryByHeader=”user-agentVaryByCustom=”BrowserLocation=”Client%>


 


1. Varying cache contents by parameter:


None : indicates the different cached version of a page should not be created when the page is requested with different parameters.


* : indicates the different cached version of a page should be created whenever the page is requested with different parameters.


 


<%@ OutputCache Duration=”60varyByParam=”* %>


 


Eg:


<%@ OutputCache Duration=”60varyByParam=”PID; PCatId %>


 


This will creates different cached copies of the page depending on the values of the PID and PCatId parameters.


Note: Each cached copy of the page eats away at memory. So the more versions of the page that you cached, the more server resources are consumed.


 


2. Varying cache by Header:


 


To cache different version of a page depending on the browser.


<%@ OutputCache Duration=”20varyByParam=”*VaryByHeader=”User-Agent%>


 


3. Varying cache contents by Custom string:


 


This attribute enables you to control the sensitivity of the page output caching.


<%@ OutputCache Duration=”60varyByParam=”*varyByCustom=”Browser%>


 


4. Storage for cached page:


 


The following are the location values used to cache the pages on the desied location.



  1. Default: The cached page is stored on both places i.e server and client.The page is cached in the server's memory, and the proper headers are sent to the browser requesting the page to cause the browser to create a cached copy.

  2. Any: This is the default value. The page can be stored in any location i.e server, client location or any downstream server.

  3. Client: The output of the page is cached at the browser.

  4. Downstream: Page cached at any downstream server.

  5. None: No page caching should be performed.

  6. Server: The page cached at the server location.


<%@ OutputCache Duration=”20varyByParam=”*Location=”client %>


 


Fragment Caching:


 


The fragment caching allows user to cache the part of the page rather than the whole part. The fragment caching is implemented with user controls. Here user can define different areas of a page by creating separate user controls for each area of the page. With in each user control, you can use the OutputCache directive to cache the page.


 


Eg. UserBanner.ascx


 


<%@ Outputcache duration=”60varybyparams=”*%>


<asp: DataGrid id=”dgrdproductrunat=”server/>


 


Home.aspx


 


<%@Register Tag Prefix=”userCtltagname=”userbannersrc=”userBanner.ascx"%>


<userCtl:userbanner runat=”server/>


 


Note: This user control can be used in any number of pages, making it cached will help us to improve the performance of the site.


 


Data Caching:


 


Caching the data displayed on a page makes more sense than caching the page itself. Caching database records can significantly improve the performance of the Web site. Instead of retrieving the employee information from a database table every time you need to display the information on a page, you can retrieve the information directly from memory.


 


Cache object is used to cache the items in memory.


 


Eg.


Cache.Item(“cacheItem”) = “Cache this value


Cache(“cacheItem”) = “Cache this value


 


Dim colState as Hashtable


colState.Add (“CA”,” california ”)


colState.Add (“WA”,”washington”)


Cache (“States”) =colState


 


Remove item from the cache:


Cache. Remove (“cacheItem”)


 


Note: Cache object can add any type of object i.e simple string object, Collection Object or DataSet object. DataSet object can improve the performance of the Web Site to a large extent but care should be taken while using this object.


  << Prev: Example for XML Handling Using ASP. Net. Next: GridView Control >>
Aspnet Tutorial Home
Give feedback and win a prize.

 
   Printer Friendly
   Email to a friend
   Add to my Favourites    
  Download PDF version
   Report Bad Submissions
   Submit Feedback
 
  Delicious   Digg   Technorati   Blink   Furl   Reddit   Newsvine   Google Click each image to add
this page to each site.
 
 
Welcome Guest Signup
MEMBER'S PANEL
EMAIL
PASSWORD
Forgot your password?
New User? Click Here!
 
Resend Activation Email!
 
SEARCH
 
 
LINKS
MSN
Video Surveillance
Skype vs. sipcall

 
ADVERTISEMENT
Partner List
Code Project
ASP Alliance
More
 
 
 
 

Home | Login | About Us | Contact Us | Privacy Policy | Advertising