Caching in ASP.NET advantage and example

Caching in ASP.NET

Today i want to discuss, how to improve web performance in asp.net. One of the approach are using Caching in asp.net application. The caching is a must in a Web application right now. This is because the caching will fasten access data directly from memory(RAM) rather than access in Hard Disk.

This are advantage of using Caching in Web Application

Advantage :

  • Reduce round-trips: Content cached at the client or in proxies can eliminate web server round-trips. Content cached at the web server can eliminate database round-trips.
  • Move content closer to clients: The farther away from clients content is located, the longer it takes to retrieve that content.
  • Avoid time-consuming processes of regenerating reusable content: For content that takes a lot of time or resources to generate, system performance and scalability are improved if you can generate content once and then reuse it many times.
  • Optimize state management: Caching state information at the client is more scalable than storing it in a central location

use caching in ASP.NET is very simple. See the code below for example :

  //store value into cache
  HttpContext.Current.Cache["<cache key name>"] = new DataTable();

  //access value from cache
  if (HttpContext.Current.Cache["<cache key name>"] != null)//checking if cache is null or not
  {
      DataTable table = (DataTable)HttpContext.Current.Cache["<cache key name>"];
  }


By
NOTE : – If You have Found this post Helpful, I will appreciate if you can Share it on Facebook, Twitter and Other Social Media Sites. Thanks =)

Popular posts from this blog

How to create zip file to download in JSP- Servlet

How to create DataGrid or GridView in JSP - Servlet

Pinging in ASP.NET Example