--------------------------------------------------------------------------------------------------------------------------
Prepared By : Uday Shah (HOD) - IT
E-Mail : rupareleducation@gmail.com
Contact No : 7600044051
:: Caching Application Page and Data ::
What is Caching?
·
Caching
is a technique of storing frequently used data and information in memory, so
that, when the same data and 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.
·
Caching
places frequently used data in quickly accessed media such as the random access
memory of the computer.
·
The
ASP.NET runtime includes a key-value map of CLR objects called cache.
·
This
resides with the application and is available via the HttpContext and
System.Web.UI.Page.
Page Output
Cache
·
A typical kind of
caching for server applications is output caching.
·
PageOutput
caching enables you to store rendered HTML.
·
The stored HTML
is served in response to subsequent requests for the same page.
·
You can use
output caching to cache a whole Web page or just the output of an ASP.NET
control.
·
PageOutput
caching is extensible.
·
You can use a
custom output cache provider that can store data on any data storage device.
·
The page output
cache stores the contents of a processed ASP.NET page in memory.
·
Partial-page
caching persists specified portions of a page and lets other portions of the
page be created dynamically.
·
Partial-page
caching can work in two ways: control caching and post-cache substitution.
·
This can be
achieved by partial or fragment caching.
·
In this caching,
specific parts of a web page are cached, and the remaining content of the web
page is refreshed each time the page is requested.
Absolute
Expiration
·
Absolute
expiration means that your data will be removed from cache after fixed amount
of time either it is accessed or not.
·
Generally we use
it when we are displaying data which is changing but we can afford to display
outdated data in our pages.
·
This will be
absolute expiration whether cache will be used or not It will expire the cache.
·
This type of
expiration used to cache data which are not frequently changing.
Sliding
Expiration
·
Sliding expiration
means It will expire cache after time period at the time of activating cache if
any request is not made during this time period.
·
This type of
expiration is useful when there are so many data to cache.
·
So It will put
those items in the cache which are frequently used in the application.
·
So it will not
going to use unnecessary memory.
Data
Caching:
·
The main aspect
of data caching is caching the data source controls.
·
We have already
discussed that the data source controls represent data in a data source, like a
database or an XML file.
·
These controls
derive from the abstract class DataSourceControl
·
This is the most
flexible type of caching but requires some code to implement.
·
The basic
principle is that you add items that are expensive to create to a special
built-in collection object (called cache), which is globally available.
·
Unlike the
application object it is thread-safe i.e. you need not lock or unlock the
collection before adding or removing an item.
·
Cache items are
removed automatically when expired. Items in the cache support dependencies.
·
You can add an
item to the cache by simply by assigning a new key name. Like: Cache[“key”] =
item;
:: Best of Luck ::
https://myshopprime.com/uday.shah3/shop