One of the most important factors in building high-performance, scalable Web applications is the ability to store items, whether data objects, pages, or parts of a page, in memory the initial time they are requested. You can cache, or store, these items on the Web server or other software in the request stream, such as the proxy server or browser. This allows you to avoid recreating information that satisfied a previous request, particularly information that demands significant processor time or other resources. ASP.NET caching allows you to use a number of techniques to store page output or application data across HTTP requests and reuse it.
Caching is a technique of persisting the data in memory for immediate access to requesting program calls.
Advantages of Caching:-
1. Reduce hosting server round-trips
When content is cached at the client or in proxies, it cause minimum request to server.
2. Reduce database server round-trips
When content is cached at the web server, it can eliminate the database request.
3. Reduce network traffic
When content is cached at the client side, it also reduce the network traffic.
4. Avoid time-consumption for regenerating reusable content
When reusable content is cached, it avoid the time consumption for regenerating reusable content.
5. Improve performance
Since cached content reduce round-trips, network traffic and avoid time consumption for regenerating reusable content which cause a boost in the performance.
Types of Caching:
The ASP.NET Web Application Framework supports the following types of caching:
1. Page Output Caching
2. Fragment Caching (Partial Page Caching)
3. Data Caching
1. Page Output Caching
A typical kind of caching for server applications is output caching. Output 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 web user control.
@ OutputCache Directive:-
Attributes:
Duration: - It is used to define the time in seconds to cache the page response in memory.
VaryByParam:- It is used to set the value to get Single Response or Multiple Response.
Ex:
<%@ OutputCache Duration="60" VaryByParam="None" %>
2. Fragment Caching
“Fragment caching allows to cache specific portions of the page rather than the whole page. It is done by implementing the page in different parts by creating everything in form of user controls and caching each user control individually.”
3. 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.
Caching is a technique of persisting the data in memory for immediate access to requesting program calls.
Advantages of Caching:-
1. Reduce hosting server round-trips
When content is cached at the client or in proxies, it cause minimum request to server.
2. Reduce database server round-trips
When content is cached at the web server, it can eliminate the database request.
3. Reduce network traffic
When content is cached at the client side, it also reduce the network traffic.
4. Avoid time-consumption for regenerating reusable content
When reusable content is cached, it avoid the time consumption for regenerating reusable content.
5. Improve performance
Since cached content reduce round-trips, network traffic and avoid time consumption for regenerating reusable content which cause a boost in the performance.
Types of Caching:
The ASP.NET Web Application Framework supports the following types of caching:
1. Page Output Caching
2. Fragment Caching (Partial Page Caching)
3. Data Caching
1. Page Output Caching
A typical kind of caching for server applications is output caching. Output 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 web user control.
@ OutputCache Directive:-
Attributes:
Duration: - It is used to define the time in seconds to cache the page response in memory.
VaryByParam:- It is used to set the value to get Single Response or Multiple Response.
Ex:
<%@ OutputCache Duration="60" VaryByParam="None" %>
2. Fragment Caching
“Fragment caching allows to cache specific portions of the page rather than the whole page. It is done by implementing the page in different parts by creating everything in form of user controls and caching each user control individually.”
3. 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.
No comments:
Post a Comment