Wrox Programmer Forums
VS.NET 2002/2003 Discussions about the Visual Studio.NET programming environment, the 2002 (1.0) and 2003 (1.1). ** Please don't post code questions here ** For issues specific to a particular language in .NET, please see the other forum categories.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VS.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old February 17th, 2004, 08:00 AM
Authorized User
Join Date: Feb 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default .NEt Caching

One of the new features in ASP.NET is a system for caching page and application data, so that you don’t have to perform the same expensive process every time someone views a page.

Page caching: Caching can be performed on a per-page basis, or on a per-user-control basis, letting you store part or whole pages in a cache, and customise their expiration.

Page caching is controlled by the <%@ OutputCache %> directive, which has two compulsory parameters: · Duration: The number of seconds to keep the page in the cache · VaryByParam: The query string parameters to use when determining page uniqueness. For example, news articles may have urls like news.aspx?id=2, news.aspx?id=3. In this case, you would want to store a different entry in the cache for news article 2 than for article 3, so you could vary by the “id” parameter.

Object caching: You can insert a value into the Cache object giving it a unique key and set its absolute or relative expiration time.

For example, we may want to cache some xml resulting from a complicated process, and store it for 12 hours. Each time we use the xml we check if it’s still in the cache:

Prioritise items in the cache: Because the cache stores items in memory, it may need to boot out some items to free up memory. Each time you insert something into the cache, use the overloaded version of Insert that allows you to indicate how important that item is, using one of the CacheItemPriority enumeration values.

Don’t cache everything: Again, because the cache is in-memory, you need to trade-off whether to regenerate items, or store them in memory.

Single point of maintenance: No-one wants to dig through code to find cache settings, so the usual rule applies here. You’ll find it easier in the long run if you store your cache settings in a central location.

Please provide your feedback as this would enable me and encourage me in posting some articles for everyone here.

Srimahavishnu Vadlapatla
( Mahavishnu / Vishnu)
Srimahavishnu Vadlapatla
(Mahavishnu / Vishnu)
&nbsp;E-Mail Me

Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP.Net Caching sohrabus ASP.NET 2.0 Professional 1 January 26th, 2007 11:29 AM
Caching in .NET derekl ASP.NET 1.0 and 1.1 Basics 1 August 21st, 2006 11:05 AM
.NET|Issue with .aspx pages caching at Server side purtimalhotra ASP.NET 1.0 and 1.1 Professional 0 July 6th, 2006 12:13 AM
Plz explain .NET Caching Options ? amitjoshipune .NET Framework 2.0 0 March 31st, 2005 03:36 AM
Caching in .Net Mahavishnu ASP.NET 1.x and 2.0 Application Design 1 February 17th, 2004 09:07 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.