Caching in ASP.NET

Cache means to store it in a temp memory for future use. Caching is often used to store information that’s frequently served to users in a faster manner.
In this blog, I will write about Caching in

What is caching in ASP.Net

Retrieving same information again and again from the actual sources does not make any sense. This might impact your web page performance. Caching is a temporary storage of an object. 

With careful optimization, you can reduce the time and reduce the burden imposed on the database to a certain extent, but you can never eliminate it. But with a system that uses caching, some data requests won’t require a database connection and a query. Instead, they’ll retrieve the information directly from server memory, which is a much faster proposition.

Types of Caching

ASP.NET really has two types of caching. Your applications can and should use both types because they complement each other:

Output caching: This is the simplest type of caching. It stores a copy of the final rendered HTML page that is sent to the client. The next client that submits a request for this page doesn’t actually run the page. Instead, the final HTML output is sent automatically. The time that would have been required to run the page and its code is completely reclaimed.

<%@ OutputCache Duration=”20″ VaryByParam=”None” %>

Data caching: This is carried out manually in your code. To use data caching, you store important pieces of information that are time-consuming to reconstruct (such as a DataSet retrieved from a database) in the cache. Other pages can check for the existence of this information and use it, thereby bypassing the steps ordinarily required to retrieve it. Data caching is conceptually the same as using application state, but it’s much more server-friendly because items will be removed from the cache automatically when it grows too large and performance could be affected. Items can also be set to expire automatically. 

Benefits of Caching

  • Increase Page Performance
  • Reduce server load

Few Popular blogs on SharePointCafe.Net

ASP.Net Core Tutorial
ASP.Net Tutorial
Learn WCF

Leave a Comment