Tuesday, August 29, 2006

Increase Web site performance with ASP.NET caching

While functionality is the number one goal of Web development, performance seems to be a close second. After all, a site that isn't used serves no purpose. Caching frequently accessed Web page data is one way to positively impact a Web application's performance. ASP.NET includes caching support that is easily incorporated in your application to boost application performance.

ASP.NET 1.x provides three ways to incorporate caching in a Web application:

  • Page Output caching: allows you to cache the dynamically generated page content.
  • Page Fragment caching: caches portions of a Web page.
  • Page Data caching: programmatically caches data/objects within a Web page.
In this article, I will focus my attention on Page Output caching.

Page Output caching
Output caching is applicable when the contents of an entire page are relatively static so it may be cached. Caching frequently accessed pages can result in substantial throughput gains. The way it works is initial page requests are generated dynamically with all subsequent requests served from the cache. The result is an enormous performance gain with heavily used applications.

The main aspect of caching a page is the expiration date. It determines how long content will be retained in the cache before it is reloaded from the source. It is accessible via code or with the page-level OutputCache directive. It includes the Duration parameter for specifying how long an item will be cached (in seconds). Along with Duration, the OutputCache directive contains the following attributes:

  • Location
    : The location of the cache. Valid values include Any, Client, Downstream, None, Server, and ServerAndClient. The default value is Any.
  • CacheProfile
    : The name of the cache settings to associate with the page. It is an optional element with no default value.
  • NoStore
    : A Boolean value signaling whether to prevent secondary storage of sensitive data.
  • Shared
    : A Boolean value that determines whether user control output can be shared with multiple pages.
  • VaryByCustom
    : Any text that represents custom output caching requirements.
  • VaryByHeader
    : A semicolon-separated list of HTTP headers used to vary the output cache.
  • VaryByParam
    : A semicolon-separated list of strings used to vary the output cache.
The key elements used most frequently are Duration and VaryByParam, which allows you to create different page level caches based on parameters.

These parameters correspond to querystring values sent with HTTP GET requests or form parameters sent along with HTTP POST requests. When this attribute is set to multiple parameters, the output cache contains a different version of the requested document for each combination of specified parameters. Possible values include none, an asterisk (*), and any valid query string or POST parameter name.

Read more

Tags: , , , , , , , , , , , , , ,

Can't find what you're looking for? Try Google Search!
Google
 
Web eshwar123.blogspot.com

Comments on "Increase Web site performance with ASP.NET caching"