07-05-2012, 12:17 PM
exploring catching in aspnet
[attachment=21452]
Introduction
In our last project, we developed a site for a large number of users. Larger number of client means larger number of requests to your web server and heavy load on the network causing performance issue. For solving this problem, I worked on using caching on our web application. I then thought, why not write an article on CodeProject on it. I am writing this article about whatever I have learned from my practical experience, net surfing, and different books for completing my assignment. Most of the things are very commonly known to a lot of the readers, but I have tried to write in a different way so that it can be understood by beginners also. An interesting thing that I have found while writing the article is setting up different locations for caching. I have also given the corresponding Visio diagram. Hope you will like it.
What is Caching?
Web applications are accessed by multiple users. A web site can have a heavy load on the site which can increase exponentially, which can slow down the server as well as the access of the site. Slow access is the most common problem for web sites when accessed by a large number of clients simultaneously. For resolving this problem, we can use a high level of hardware configuration, load balancer, high bandwidth, but load is not the only reason that makes a website slow, so we need to provide a kind of mechanism which will also provide fast data access and provide performance improvements. Caching provides the solution.
Caching is a technique where we can store frequently used data, and web pages are stored temporarily on the local hard disk for later retrieval. This technique improves the access time when multiple users access a web site simultaneously, or a single user accesses a web site multiple times. Caching for web applications can occur on the client (browser caching), on a server between the client and the web server, (proxy caching / reverse proxy caching), and on the web server itself (page caching or data caching).
We can choose a big amount of time to store cached data so it improves the performance but it does not solve our purpose every time. If we consider the load on a Web Server we have to consider the location where the cached data is stored. The following section will describe different locations for storing cached data.
Different Caching Locations
Caching in a web application can be done either on the client side (client browser), in between the client and the server (proxy and reverse proxy caching), or on the server side (data caching/page output caching). So we can classify caching locations like this:
1. Client Caching
2. Proxy Caching
3. Reverse Proxy Caching
4. Web Server Caching
1. Client Caching: In Client Caching, the client browser performs caching by storing cached data on the local disk as a temporary file or in the browser internal memory. This provides quick access of some information which reduces the network load and the server load also. This information can't be shared by other clients so it is client specific.
Client caching
Advantages
1. Data that is cached on the local client can be easily accessed
2. Reduces network traffic
Disadvantages
1. Cached data is totally browser dependent, so it is not shareable
2. Proxy Caching: The main disadvantage of client caching is data that is stored on the client browser is client specific. Proxy caching uses a dedicated server that stores caching information in between the client and the web server in a shared location so that all clients can use the 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.