Mega Code Archive

 
Categories / ASP.Net Tutorial / Cache
 

Specifying the Cache Location

use the Location attribute of the <%@ OutputCache %> to specify  where a page is cached.  This attribute accepts the following values: Any: The page is cached on the browser, proxy servers, and web server (the default value). Client: The page is cached only on the browser. Downstream: The page is cached on the browser and any proxy servers but not the web server. None: The page is not cached. Server: The page is cached on the web server but not the browser or any proxy servers. ServerAndClient: The page is cached on the browser and web server, but not on any proxy servers. <%@ Page Language="C#" %> <%@ OutputCache Duration="3600" VaryByParam="none" Location="Client" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server">     void Page_Load()     {         Random rnd = new Random();         lblRandom.Text = rnd.Next(10).ToString();     } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server">     <title>Cache Location</title> </head> <body>     <form id="form1" runat="server">     <div>     <%= DateTime.Now.ToString("T") %>     <hr />     Your random number is:     <asp:Label         id="lblRandom"         Runat="server" />     <br /><br />     <a href="CacheLocation.aspx">Request Page</a>     </div>     </form> </body> </html>