ASP.Net/Page/OutputCache
Содержание
Asp cache by browser
<source lang="csharp">
<%@Page Language="C#"%> <%@OutputCache Duration="10" VaryByParam="none" VaryByCustom="browser" %> <html> <body> <asp:panel id="pnlTest" runat="server">
Page executed: <% = DateTime.Now %>
</asp:panel> </body> </html>
</source>
Cache duration (C#)
<source lang="csharp">
<%@Page Language="C#"%> <%@OutputCache Duration="10" VaryByParam="none" %> <html> <body> <asp:panel id="pnlTest" runat="server">
Page executed: <% = DateTime.Now %>
</asp:panel> </body> </html>
</source>
Get server time (C#)
<source lang="csharp">
<%@ OutputCache Duration="60" VaryByParam="none" %> <script language="c#" runat = "server">
string ServerTime() { return System.DateTime.Now.ToLongTimeString(); }
</script> The time on your web server is : <%=ServerTime() %>
</source>
Using the OutputCache Directive (VB.net)
<source lang="csharp">
<%@ Page Language=VB Debug=true %> <%@ OutputCache Duration=30 VaryByParam=none%> <script runat=server> Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)
lbl1.Text = "The current time on the server is " & TimeOfDay()
End Sub </script> <HTML> <HEAD> <TITLE>Using the OutputCache Directive</TITLE> </HEAD> <Body LEFTMARGIN="40"> <form runat="server"> <asp:label id="lbl1" runat="server"/> </Form> </BODY> </HTML>
</source>