Submitted To: Mr. R.K. Singla Submitted By:navneet Kaur Mca 5 Sem Morning Roll No. 14
Submitted To: Mr. R.K. Singla Submitted By:navneet Kaur Mca 5 Sem Morning Roll No. 14
Client Caching
Proxy Caching
Reverse Proxy Caching
Web Server Caching
1. Client Caching :
In Client Caching Client Browser perform caching by
storing cached data on local disk as temporary file or
browser internal memory. This provide quick access of
some information by client which reduce the network
load and server load also. This information can't be
shared by other clients so it is client specific.
Cont…
Advantages
Data that are cached on local client can be easily accessed
Reduce Network Traffic
Disadvantages
Cached data are totally browser dependent, so it is not shareable
2. Proxy Caching :
Main disadvantage of Client caching was data that are store on
client browser are client specific. Proxy Caching technique used a
dedicated server that store caching information in between client
and web server in a shared location, that all client can used same
shared data. The proxy server (e.g. Microsoft Proxy Server ) fulfills all
the requests for the Web page without sending out the request to
the actual Web server over the Internet, resulting in faster access.
Cache array
Proxy caches are often located near network gateways to reduce the
bandwidth . Some times Multiple Proxy Cache server is used for
larger number of client. This is called Cache Array.
Contd....
Advantages
Data that are cached on proxy server can a
accessed easily
Reduce Network Traffic
Disadvantages
It a Deployment and Infrastructure overhead
to maintain a Proxy Cache Server
3. Reverse Proxy Caching :
Some Proxy Cache server can placed in front of web server to reduce
the number of requests that they receive. This allows the proxy
server to respond to the frequently received requests and pass the
other requests to the Web server. This is called a reverse proxy.
Contd…
Advantages
Data that are cached on reverse proxy server can a accessed easily
Web server reduce the number of request
Disadvantages
As the Server configured in front of Web sever some what it
increases the network traffic.
4. Web Server Caching :
Advantages
Improve the performance of sites by decreasing the round trip of
data retrieving from database or some other server
Disadvantages
Increase the Network Load
Caching Opportunity in
ASP.NET
ASP.NET provides support for
page
partial page (Fragment)
data caching
@ OutputCache Duration="60"
VaryByParam="Category"
.
Data Caching
Data Caching can tremendously increase performance
since each time the data is requested you can turn to the
Cache object rather than going to the database and
fetching the result.
Here caching of data as objects is done. We can
store objects in memory and use them across various
pages in our application. This feature is implemented
using the Cache class. This cache has a lifetime
equivalent to that of the application. Objects can be
stored as name value pairs in the cache. A string value
can be inserted into the cache as follows:
Cache["name"]="Smitha";
Contd…
The stored string value can be retrieved like this:
if (Cache["name"] != null)
Label1.Text= Cache["name"].ToString();
To insert objects into the cache, the Add method or
different versions of the Insert method of the Cache class
can be used. These methods allow us to use the more
powerful features provided by the Cache class. One of the
overloads of the Insert method is used as follows:
Cache.Insert("Name", strName,
new
CacheDependency(Server.MapPath("name.txt"),
DateTime.Now.AddMinutes(2), TimeSpan.Zero);
Contd..
The first two parameters are the key and the object
to be inserted.
The third parameter is of type CacheDependency and
helps us set a dependency of this value to the file named
name.txt.
So whenever this file changes, the value in the cache is
removed. We can specify null to indicate no dependency.
The fourth parameter specifies the time at which the
value should be removed from cache.
The last parameter is the sliding expiration
parameter which shows the time interval after which the
item is to be removed from the cache after its last accessed
time.
Contd…
The cache automatically removes the least used items
from memory, when system memory becomes low.
This process is called scavenging. We can specify
priority values for items we add to the cache so that
some items are given more priority than others:
Cache.Insert("Name", strName,
new
CacheDependency(Server.MapPath("name.txt"),
DateTime.Now.AddMinutes(2), TimeSpan.Zero,
CacheItemPriority.High, null);
The CacheItemPriority enumeration has members to
set various priority values. The
CacheItemPriority.High assigns a priority level to an
item so that the item is least likely to be deleted from the
cache.
Caching Page Fragments
Fragment Caching refers to caching the sections of the
page. These sections are most commonly UserControls.
Page fragment caching allows you to cache the small
portion of the page instead of caching the whole page.
@ OutputCache Duration="120"
VaryByParam="CategoryID;SelectedID"
In the Page directive above we have cached CategoryID
and SelectedID for 120 seconds. Both of these are the
query string parameters.
This means that if the first user request CategoryID = 2 and
the second user request the same CategoryID than the
second user will recieve the contents from the cache object
instead of going to the database and pulling records.
Contd…
@ OutputCache Duration="120"
VaryByParam="none"
VaryByControl="Category"
The VaryByControl attribute can only be used in
fragment caching.
You can use this to cache the value of the controls.
These controls can be any server controls like
dropdownlist or datagrid.
When using fragment caching you only need to put the
cache directive in the user control and not on the page.
Automatic Data Removal