Improving Performance By Using ASP.NET Caching
Improving Performance By Using ASP.NET Caching
What is ASP.NET caching mechanism?
When to use caching? and
how can I use it in
order to improve my site performance? are the
questions this post series is going to answer.
Introduction
The caching mechanism is one of the most powerful feature shipped with ASP.NET.
Even so, most developers don’t understand its power and misuse it. I had the
opportunity to see and to hear about a lot of developer mistakes in the area of bad
caching implementation or in the other hand not using caching mechanism when
appropriate.
What is ASP.NET Caching?
The caching mechanism was made to store frequently accessed data in memory for a
fast retrieval latter. When the data is stored in memory it can be retrieved faster then
in all other storage mechanisms and therefore can boost performance. For example if
I have an XML file that holds application relevant data I can read it once and cache
the data. When I cache the data I won’t need to use another I/O operations of reading
the file in order to use the data again. The data will be available in memory and will be
retrieved faster. This is one example of how to use cache but the thing you need to
ask yourself now is what if I make an update to the file? how the cache mechanism will
know that? these questions are good but the ASP.NET caching can handle those things
and what you need to understand is how to tell it to do so.
ASP.NET Caching Types
ASP.NET provide two types of caching:
- Application caching – A key value collection that stores the objects in memory
and manage the objects lifetime in memory automatically. - Page output cache – A mechanism to cache whole pages or part of them in order
to save time and resources in rendering them again in future requests.
Summary
The post introduced the ASP.NET caching concept and described the types of caching in
general. The following posts in the series will get into more details about how and
what to do in order improve performance by using caching.