.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.
Thanks
Srimahavishnu Vadlapatla
( Mahavishnu / Vishnu)
__________________
Thanks!
Srimahavishnu Vadlapatla
(Mahavishnu / Vishnu)
E-Mail Me
|