Click here to Skip to main content
15,891,423 members
Articles / Web Development / ASP.NET

Caching in ASP.NET

Rate me:
Please Sign up or sign in to vote.
4.79/5 (204 votes)
21 Feb 2004CPOL6 min read 704.6K   10.9K   214  
An overview of caching in ASP.NET.
<%@ Page language="c#" %>
<%@ OutputCache Duration=10 VaryByParam="id" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
	<HEAD>
		<title>PageCachingByParam</title>
		<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
		<meta name="CODE_LANGUAGE" Content="C#">
		<meta name="vs_defaultClientScript" content="JavaScript">
		<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
	</HEAD>
	<body MS_POSITIONING="GridLayout">
		<p>
			<asp:HyperLink id="HyperLink2" style="Z-INDEX: 104; LEFT: 8px; POSITION: absolute; TOP: 120px"
				runat="server" Width="40px" NavigateUrl="index.htm" Height="24px" Font-Size="X-Small" Font-Names="Verdana">Index</asp:HyperLink>Output 
			cached for 10 seconds and varied according to the id parameter in querystring. 
			Try F5 to reload the page.</p>
		<script runat="server">		
		public void Page_Load()
		{
			Label1.Text = "Page created at: " + DateTime.Now.ToString();
		}				
		</script>
		<asp:Label id="Label1" style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 72px" runat="server"
			Width="256px"></asp:Label>
	</body>
</HTML>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
The Code Project
United States United States
Smitha is a software developer, and has been in the industry since January 2000. She has experience in ASP.NET, C#, Windows Forms, Visual Basic, ASP, JavaScript, VBScript, and HTML. She has been with CodeProject since 2003 and currently works as Senior Editor.

In her free time, she tries out new dishes, reads a little, and puts together jigsaw puzzles. Originally from Trivandrum, Smitha currently lives with her husband and fellow CP'ian Nish [^] and her son Rohan in Columbus, Ohio.

Comments and Discussions