Effective Caching techniques

Caching is the technique provided within the asp.net framework to optimize the performance of the web applications with less effort and time.
Your application can be optimized upto 80% more faster with only 20% effort for any type of your asp.net application.

What actually does the Caching:

Caching actually stores the frequently used data on the memory so that application can load data from memory rather tan file or database which makes web application faster.

The .Net framework 2.0 provides the Cache object so that you can easily take the advantage of the improved performance Caching.
There are 2 types of Caching
i. Application Caching
ii. Page Output Caching

Application Caching:

Add objects that need to be cached, on the Cache collection so that you can retrieve objects later. Objects stored on the cache can be retrieved between sessions and between page requests.

Effective Use of Application Cache:

Objects on the cache can be retrieved between sessions and the page requests. The advantage of application cache really  comes here. For eg: You are loading a set of results from the database that is common for all users. The result is actually the result of complex calculations. Instead going for complex calculation on each page requests, you can once create a result and store on the cache. On the subseuest page requests, application will retrive the data from the cache quickly instead of spending lots of time of calculation.
Also you can use the dependency to remvoe the cache whenever the cache data is invalid(some changes on the datasource).

Page Output Caching

Asp.net 2.0 supports page output caching to improve performance caching to improve performance and to reduce server load. With page output caching, asp.net can keep a copy of page output in the memory. Next time user requests it even its a different user, asp.net can return the page almost instansly. If your page has lots of server controls and takes a lot of time to render output, caching can significanlty improve performance.

If output of the page is user depnendent or querysting dependent( i.e. same page loads different type of data based on querysting values), the same page output fromt he cache may not valid for all the user or it will render same data regarding the the querystirng value on the url. The problem can also be solved with some configuration while defining page output cache. Asp.net gives al the configuration option to meet almost any requirements.

How to use:

- Use @Output Cache directive on a page level
- Use VaryByParam, VaryByCustom or other options if necessary.
- VaryByParam allows you to output cache for each query string combination.

, , , ,

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Share to Facebook Share to Twitter Stumble It Share on Tumblr Digg More...