is a technique of storing frequently used data/information in memory, so that,
when the same data/information is needed next time, it could be directly
retrieved from the memory instead of being generated by the application.
Caching is extremely important for performance
boosting in ASP.Net, as the pages and controls are dynamically generated here.
It is especially important for data related transactions, as these are
expensive in terms of response time.
You can access items in the cache using an indexer and
may control the lifetime of objects in the cache and set up links between the
cached objects and their physical sources.
In short:-Caching is a feature that stores
data in local memory, allowing incoming requests to be served from memory
Benefits of Caching
The following are the benefits of using
Faster page rendering
Minimization of database hits
Minimization of the consumption of server resources
Types of Caching:-
Caching in ASP.NET can be of the following
Page Output Caching
Page Fragment Caching
Page Output Caching:
cache stores a copy of the finally rendered HTML pages or part of pages sent to
the client. When the next client requests for this page, instead of
regenerating the page, a cached copy of the page is sent, thus saving time.
Syntax of output caching
At design time:-
<%@ OutputCache Duration="no of
seconds" Location="Any | Client | Server | None"
This type of caching is used with user
controls in asp.net.
Syntax of fragment
Duration="15" VaryByParam="*" %>
This directive is placed at the top of any
User Control (.ascx file).
Data caching means
caching data from a data source. As long as the cache is not expired, a request
for the data will be fulfilled from the cache. When the cache is expired, fresh
data is obtained by the data source and the cache is refilled.
The Add/Insert method of the Cache class
is used to add/insert an item into the cache. The Remove method removes a
specified item from the cache. The Cache class contains the following
properties and methods.
you like this post then please join this site and like it’s Facebook page
for getting updates and contributing into the problem solving of members of this blog.you can also post your issues on this blog's Facebook page and can get the solutions.