Caching Overview
Caching is a technique this is widely used in computing to increase performance by keeping frequently accessed or Expensiv e data in memory. In the context of a WEB application, caching are used to hold onto pages or data across HTTP requests and reuse them t the expense of recreating them.
ASP.net has two kinds of caching that can is utilized by WEB applications.
- Caching The dynamic response generated by a request is known as Output Caching.
- The caching of arbitrary objects programmatically is known as Data caching. To support this, ASP.net provides a full featured Cache engine which allows programmers to easily hold the data onto across Uests.
Output caching is useful the contents of a entire page can be cached. On a heavily accessed site, caching frequently accessed pages for even a minute at a time can result in substantial throug Hput gains. While a page was cached by the output cache, subsequent requests for this page are served from the output page without exec Uting the code that created it.
Sometimes it ' s not practical to cache a entire page--perhaps portions of the page must is created or customized for each Request. In this case, it's oftentimes worthwhile to identify objects or data that are expensive to construct that are for Caching. Once these items are identified, they can is created Once and then cached for some.
Choosing the time to cache a item can make for an interesting decision. For some items, the data might was refreshed at regular intervals or the data are valid for a certain to amount of time. In this case, the cache item can be given a expiration policy that would cause them to be removed from the cache when they ' Re expired. Code that accesses the cache item simply checks for the absence of the item, and recreates it if necessary.
The asp.net cache supports file and cache key dependencies, allowing developers to make a cache item dependent on a Exter NAL file or another cache item. This technique can is used to invalidate the items when their underlying data source changes.