Search 
DailyCoding > Web

How to cache a page output in ASP.NET

how to do caching in asp.net to save the cpu time and do fast processing of incomming request
Author admin on May 19, 2008 1 Comments
Rate it    (Rated 5 by 1 people)
402 Views

If your ASP.NET page contains processing and db calls and you know that it's output is not changing that frequently then you must cache you page out. It is easy to do this in ASP.NET

<%@ outputcache duration="3600" varybyparam="none" %>

Above code will cache the page for 3600 seconds, whihc means that page will be processed only once in every 1 hour

In case the page content vary by url parameters then you must specify the name of all parameters separated by semi-colon as shown in below example

<%@ outputcache duration="100" varybyparam="employeeId;companyId" %>

ASP.NET will automatically take care of in case parameters are changed and adjust the caching accordingly.

ASP.NET | Data

Discussion

Sachin Gaur On May 21, 2008 07:28 AM
Hey thanks buddy!!!
It really helps me a lot.

Leave a Comment

Name
Email Address
Web Site
© Copyright 2008 Daily Coding • All rights reserved