Article ID: 811431 - Last Review: May 31, 2007 - Revision: 3.6 How To Cache in ASP.NET by Using Visual Basic .NETOn This PageSUMMARYThis step-by-step article describes ways to control how
ASP.NET caches Web pages and data objects. By caching, you avoid re-creating
information when you make later requests. Caching is an important technique for
building high performance and scalable server applications. In the first
request for the page, you can store data objects, pages, or parts of the page
in the memory. You can store these items on the Web server, on the proxy server, or
on the browser. MORE INFORMATIONASP.NET provides convenient methods to control caching. You
can use the @ OutputCache directive to control page output caching in ASP.NET. Use HttpCachePolicy class to store arbitrary objects, such as datasets, to the server
memory. You can store the cache in applications such as the client browser, the
proxy server, and Microsoft Internet Information Services (IIS). By using
Cache-Control HTTP Header, you can control caching. For additional information about ASP.NET output caching, click the following article number to view the article in the Microsoft Knowledge Base: 308516
(http://support.microsoft.com/kb/308516/EN-US/
)
How To Control Page Output Caching in ASP.NET by Using Visual Basic .NET
Cache ASP.NET PagesYou can cache by using the @ OutputCache directive, or programmatically through code by using Visual Basic .NET or Visual C# .NET. The @ OutputCache directive contains a Location attribute. This attribute determines the location for the cached item. You may specify one of the following locations:
The following are code samples for the @ OutputCache directive and equivalent programmatic code.
Turn Off Client and Proxy CachingTo turn off the output cache for an ASP.NET Web page at the client location and at the proxy location, set the Location attribute value to none, and then set the VaryByParam value to none in the @ OutputCache directive. Use the following code samples to turn off client and proxy caching.
Cache Arbitrary Objects in Server MemoryASP.NET includes a powerful, easy-to-use caching mechanism that you can use to store objects that require a lot of server resources to create in memory. The Cache class implements this method. Instances are private to each application and the lifetime is tied to the corresponding application. To cache the arbitrary objects in ASP.Net by using the Cache class, follow these steps:
REFERENCES For additional
information, click the following article numbers to view the articles in the
Microsoft Knowledge Base: 234067
(http://support.microsoft.com/kb/234067/EN-US/
)
How To Prevent Caching in Internet Explorer
247404
(http://support.microsoft.com/kb/247404/EN-US/
)
How to Modify the Cache-Control HTTP Header When You Use IIS
311006
(http://support.microsoft.com/kb/311006/EN-US/
)
How To Prevent Web Caching in Windows 2000
247389
(http://support.microsoft.com/kb/247389/EN-US/
)
IIS: How to Disable Caching of Specific MIME Types
313561
(http://support.microsoft.com/kb/313561/EN-US/
)
How To Set HTTP Headers for Content Expiration in IIS
For more information, visit the following Microsoft Web site: http://msdn2.microsoft.com/en-us/library/xsbfdd8c(vs.71).aspx
(http://msdn2.microsoft.com/en-us/library/xsbfdd8c(vs.71).aspx)
| Article Translations
|
Back to the top
