SlideShare a Scribd company logo
ASP.NET
CACHING
Assignment-2
Presented By:
Ashish Kumar
Mca-4th sem.
Caching
 Caching 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 places frequently used data in quickly accessed media
such as the random access memory of the computer.
Caching in ASP.Net
Different Types of Caching:
Output Caching : Output 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.
Data Caching : 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.
 Object Caching : Object caching is caching the objects on
a page, such as data-bound controls. The cached data is stored
in server memory.
 Class Caching : Web pages or web services are compiled
into a page class in the assembly, when run for the first time.
Then the assembly is cached in the server. Next time when a
request is made for the page or service, the cached assembly
is referred to When the source code is changed, the CLR
recompiles the assembly.
 Configuration Caching : Application wide
configuration information is stored in a configuration file.
Configuration caching stores the configuration information in
the server memory.
 Output Caching:
Rendering a page may involve some complex processes such as,
database access, rendering complex controls etc. Output caching
allows bypassing the round trips to server by caching data in
memory. Even the whole page could be cached.
The Output Cache directive is responsible of output caching. It
enables output caching and provides certain control over its
behavior.
Syntax:
<%@ OutputCache Duration="15" VaryByParam="None" %>
protected void Page_Load(object sender, EventArgs e)
{
Thread.Sleep(10000); Response.Write("This page was
generated and cache at:" + DateTime.Now.ToString());
}
 Data Caching
The main aspect of data caching is caching the data source
controls. like a database file. These controls derive from the
abstract class DataSourceControl and have the following
inherited properties for implementing caching:
 CacheDuration - It sets the number of seconds for which
the data source will cache data.
 CacheExpirationPolicy - It defines the cache behavior
when the data in cache has expired.
 CacheKeyDependency - It identifies a key for the controls
that auto-expires the content of its cache when removed.
 Enable Caching - It specifies whether or not to cache the
data.
Example Of Data Caching
For this example, add a label to the page, which would show the
response time for the page.
<asp:Label ID="lbltime" runat="server"></asp:Label>
Add an event handler for the page load event:
protected void Page_Load(object sender, EventArgs e) {
lbltime.Text = String.Format("Page posted at: {0}",
DateTime.Now.ToLongTimeString()); }
Object Caching
Object caching provides more flexibility than other cache
techniques. You can use object caching to place any object in the
cache. The object can be of any type a data type, a web control,
a class, a dataset object, etc. The item is added to the cache simply
by assigning a new key name, shown as follows Like:
Cache["key"] = item;

More Related Content

PPTX
Dotnet caching techniques
PDF
Webtech Conference: NoSQL and Web scalability
PPTX
Introduction to NoSQL Database
PPTX
Improving performance with cache scope in mule
PPTX
ASP.NET Lecture 7
PDF
FITC presents: Mobile & offline data synchronization in Angular JS
PPTX
[AzureCamp 24 Juin 2014] Cache Distribué par Thomas Conté
PDF
FOSSASIA 2015 - 10 Features your developers are missing when stuck with Propr...
Dotnet caching techniques
Webtech Conference: NoSQL and Web scalability
Introduction to NoSQL Database
Improving performance with cache scope in mule
ASP.NET Lecture 7
FITC presents: Mobile & offline data synchronization in Angular JS
[AzureCamp 24 Juin 2014] Cache Distribué par Thomas Conté
FOSSASIA 2015 - 10 Features your developers are missing when stuck with Propr...

What's hot (20)

PPTX
Geek Sync I Learn to Troubleshoot Query Performance in Analysis Services
PDF
MySQL Rebuild using Logical Backups
PDF
Electron, databases, and RxDB
PPTX
nHibernate Caching
PPTX
NDC Sydney - Analyzing StackExchange with Azure Data Lake
PDF
Updating materialized views and caches using kafka
RTF
SPHE-00727_description
ODP
Redis IU
PPTX
Zookeeper
PDF
Replicating application data into materialized views
PPTX
Caching in drupal
PPTX
Rapid prototyping using azure functions - A walk on the wild side
PPTX
CSCi226PPT1
PDF
U C2007 My S Q L Performance Cookbook
PPTX
Working with disconnected data in Windows Store apps
PDF
Cassandra in e-commerce
PDF
Proven Low-Cost Database for Your Business
ODP
PPTX
Node js crash course session 5
Geek Sync I Learn to Troubleshoot Query Performance in Analysis Services
MySQL Rebuild using Logical Backups
Electron, databases, and RxDB
nHibernate Caching
NDC Sydney - Analyzing StackExchange with Azure Data Lake
Updating materialized views and caches using kafka
SPHE-00727_description
Redis IU
Zookeeper
Replicating application data into materialized views
Caching in drupal
Rapid prototyping using azure functions - A walk on the wild side
CSCi226PPT1
U C2007 My S Q L Performance Cookbook
Working with disconnected data in Windows Store apps
Cassandra in e-commerce
Proven Low-Cost Database for Your Business
Node js crash course session 5
Ad

Viewers also liked (13)

ODP
As media studies evaluation
PPSX
Lizzie Borden
PPSX
The Kidnapping of Charles Augustus Lindbergh,Jr.
PPT
Java Simple Notes
ODP
As media studies evaluation 1
PPTX
Educació plàstica
PDF
3 multimedia x
PPTX
Discapacitat motora
PPTX
Unix ppt
PPTX
Software enginnering
PPTX
Save girl child
PDF
PPTX
Cyber Security PPT
As media studies evaluation
Lizzie Borden
The Kidnapping of Charles Augustus Lindbergh,Jr.
Java Simple Notes
As media studies evaluation 1
Educació plàstica
3 multimedia x
Discapacitat motora
Unix ppt
Software enginnering
Save girl child
Cyber Security PPT
Ad

Similar to Asp.net (20)

DOCX
Caching in asp.net
DOCX
Caching in asp.net
PPTX
catching in c#.pptx
PPTX
PPT
Caching By Nyros Developer
PPTX
Mini-Training: To cache or not to cache
PPTX
Sitecore Personalization on websites cached on CDN servers
PDF
Caching on the web
PPT
Caching for J2ee Enterprise Applications
PPT
Session viii(state mngtserver)
PPT
IEEE KUET SPAC presentation
PPT
aksdfhaskdjfhasdjkh
PPT
askldjfhaskdfj aslkdjfhaskdfhasjk askldf ashkdf
PPT
aergserga
PPT
salkdjfhdjkghdfkjh
PPT
awergaezrg
PPT
sergaerwga
PPT
sakdjfhaksjfhaskjh
PPT
2310 b 15
PPT
2310 b 15
Caching in asp.net
Caching in asp.net
catching in c#.pptx
Caching By Nyros Developer
Mini-Training: To cache or not to cache
Sitecore Personalization on websites cached on CDN servers
Caching on the web
Caching for J2ee Enterprise Applications
Session viii(state mngtserver)
IEEE KUET SPAC presentation
aksdfhaskdjfhasdjkh
askldjfhaskdfj aslkdjfhaskdfhasjk askldf ashkdf
aergserga
salkdjfhdjkghdfkjh
awergaezrg
sergaerwga
sakdjfhaksjfhaskjh
2310 b 15
2310 b 15

Asp.net

  • 2. Caching  Caching 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 places frequently used data in quickly accessed media such as the random access memory of the computer.
  • 3. Caching in ASP.Net Different Types of Caching: Output Caching : Output 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. Data Caching : 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.
  • 4.  Object Caching : Object caching is caching the objects on a page, such as data-bound controls. The cached data is stored in server memory.  Class Caching : Web pages or web services are compiled into a page class in the assembly, when run for the first time. Then the assembly is cached in the server. Next time when a request is made for the page or service, the cached assembly is referred to When the source code is changed, the CLR recompiles the assembly.  Configuration Caching : Application wide configuration information is stored in a configuration file. Configuration caching stores the configuration information in the server memory.
  • 5.  Output Caching: Rendering a page may involve some complex processes such as, database access, rendering complex controls etc. Output caching allows bypassing the round trips to server by caching data in memory. Even the whole page could be cached. The Output Cache directive is responsible of output caching. It enables output caching and provides certain control over its behavior. Syntax: <%@ OutputCache Duration="15" VaryByParam="None" %> protected void Page_Load(object sender, EventArgs e) { Thread.Sleep(10000); Response.Write("This page was generated and cache at:" + DateTime.Now.ToString()); }
  • 6.  Data Caching The main aspect of data caching is caching the data source controls. like a database file. These controls derive from the abstract class DataSourceControl and have the following inherited properties for implementing caching:  CacheDuration - It sets the number of seconds for which the data source will cache data.  CacheExpirationPolicy - It defines the cache behavior when the data in cache has expired.  CacheKeyDependency - It identifies a key for the controls that auto-expires the content of its cache when removed.  Enable Caching - It specifies whether or not to cache the data.
  • 7. Example Of Data Caching For this example, add a label to the page, which would show the response time for the page. <asp:Label ID="lbltime" runat="server"></asp:Label> Add an event handler for the page load event: protected void Page_Load(object sender, EventArgs e) { lbltime.Text = String.Format("Page posted at: {0}", DateTime.Now.ToLongTimeString()); }
  • 8. Object Caching Object caching provides more flexibility than other cache techniques. You can use object caching to place any object in the cache. The object can be of any type a data type, a web control, a class, a dataset object, etc. The item is added to the cache simply by assigning a new key name, shown as follows Like: Cache["key"] = item;