Optimizations: ASP.NET Caching
ASP.NET supports caching to reduce round trips to the server. ASP supports two forms of caching: output caching and data caching. Output caching improves server throughput. Data caching improves the performance on the client end.
When a Web page is accessed and a request is made, the server has to spend a bit of time producing the output. When a Web page's content does not change very much, it makes sense to cache the output so that the server does not have to regenerate it. This output caching is turned off by default, and Web pages need to turn it on specifically using the OutputCache directive. The OutputCache directive also controls the duration for which the output is cached in seconds.
Whenever an initial HTTP GET request is made for a cached page, the output for that page is cached. If an HTTP GET or HEAD request is made for the same page, ASP.NET satisfies the request from the contents of the cache (until the cached output expires). Very often, Web applications use query strings to look up data in a database and generate output. ASP.NET stores the query string, and the output cache compares query strings to verify a request's identity. HTTP POST requests are never cachedthey are always generated explicitly.
In any distributed system, one of the most important optimizations you can make is to reduce the number of round trips between the client and the server. When developing Web pages, the fewer round trips your browser clients need to make back to the server, the better.
ASP.NET provides a full-featured cache engine that can be used by pages to store objects across HTTP requests. The CLR class System.Web.Caching.Cache provides this facility. The granddaddy of all Web page classes, System.Web.UI.Page, includes a property of type cache.
The cache is a simple database supporting a simple dictionary interfacevery much like COM's property bags. When you want to cache values over a certain period of time, you put them in the cache. You can put almost whatever you want into the cache and, in addition, you have control over expiration of values.