How to cache a page output in ASP.NET

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.

3 comment(S)


Sachin Gaur on May 21, 2008 07:28 AM

Hey thanks buddy!!!
It really helps me a lot.

sdfsdf on Dec 17, 2015 02:37 AM

sdfsdfs

,jn,jnjkn on Oct 5, 2016 06:18 AM


Leave a comment