OutputCacheLocation 열거형
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
리소스에 대한 출력 캐시 HTTP 응답의 위치를 제어하기 위한 유효한 값을 지정합니다.
public enum class OutputCacheLocation
public enum OutputCacheLocation
type OutputCacheLocation =
Public Enum OutputCacheLocation
- 상속
필드
| Name | 값 | Description |
|---|---|---|
| Any | 0 | 출력 캐시는 브라우저 클라이언트(요청이 시작된 위치), 요청에 참여하는 프록시 서버(또는 다른 서버) 또는 요청이 처리된 서버에 있을 수 있습니다. 이 값은 열거형 값에 Public 해당합니다. |
| Client | 1 | 출력 캐시는 요청이 시작된 브라우저 클라이언트에 있습니다. 이 값은 열거형 값에 Private 해당합니다. |
| Downstream | 2 | 출력 캐시는 원본 서버 이외의 HTTP 1.1 캐시 지원 디바이스에 저장할 수 있습니다. 여기에는 프록시 서버 및 요청을 수행한 클라이언트가 포함됩니다. |
| Server | 3 | 출력 캐시는 요청이 처리된 웹 서버에 있습니다. 이 값은 열거형 값에 Server 해당합니다. |
| None | 4 | 요청된 페이지에 대해 출력 캐시를 사용할 수 없습니다. 이 값은 열거형 값에 NoCache 해당합니다. |
| ServerAndClient | 5 | 출력 캐시는 원본 서버 또는 요청 클라이언트에만 저장할 수 있습니다. 프록시 서버는 응답을 캐시할 수 없습니다. 이 값은 열거형 값과 Private 열거형 값의 Server 조합에 해당합니다. |
예제
다음 코드 예제에서는 서버 값을 사용하여 요청이 처리되는 웹 서버에서 페이지를 캐시하도록 지정하는 방법을 보여 줍니다.
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Data" %>
// The following OutputCache directive uses the OutputCacheLocation.Server
// enumeration value to allow output caching only on the origin server.
<%@ outputcache duration="10" varybyparam="none" Location="Server" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<script language="C#" runat="server">
protected void Page_Load(Object Src, EventArgs E)
{
DataSet ds = new DataSet();
FileStream fs = new FileStream(Server.MapPath("schemadata.xml"),FileMode.Open,FileAccess.Read);
StreamReader reader = new StreamReader(fs);
ds.ReadXml(reader);
fs.Close();
DataView Source = new DataView(ds.Tables[0]);
// Use the LiteralControl constructor to create a new
// instance of the class.
LiteralControl myLiteral = new LiteralControl();
// Set the LiteralControl.Text property to an HTML
// string and the TableName value of a data source.
myLiteral.Text = "<h6><font face=\"verdana\">Caching an XML Table: " + Source.Table.TableName + " </font></h6>";
MyDataGrid.DataSource = Source;
MyDataGrid.DataBind();
TimeMsg.Text = DateTime.Now.ToString("G");
}
</script>
<head runat="server">
<title>Using the OutputCacheLocation Enumeration </title>
</head>
<body>
<h6>Using the OutputCacheLocation Enumeration </h6>
<form id="form1" runat="server">
<ASP:DataGrid id="MyDataGrid" runat="server"
Width="900"
BackColor="#ccccff"
BorderColor="black"
ShowFooter="false"
CellPadding="3"
CellSpacing="0"
Font-Names="Verdana"
Font-Size="8pt"
HeaderStyle-BackColor="#aaaadd"
EnableViewState="false"
/>
<i>Page last generated on:</i> <asp:label id="TimeMsg" runat="server" />
</form>
</body>
</html>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Data" %>
' The following OutputCache directive uses the OutputCacheLocation.Server
' enumeration value to allow output caching only on the origin server.
<%@ outputcache duration="10" varybyparam="none" Location="Server" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<script language="vb" runat="server">
Protected Sub Page_Load(Src As [Object], E As EventArgs)
Dim ds As New DataSet()
Dim fs As New FileStream(Server.MapPath("schemadata.xml"),FileMode.Open,FileAccess.Read)
Dim reader As New StreamReader(fs)
ds.ReadXml(reader)
fs.Close()
Dim [Source] As New DataView(ds.Tables(0))
MyDataGrid.DataSource = [Source]
MyDataGrid.DataBind()
TimeMsg.Text = DateTime.Now.ToString("G")
End Sub 'Page_Load
</script>
<head runat="server">
<title>Using the OutputCacheLocation Enumeration </title>
</head>
<body>
<h4>Using the OutputCacheLocation Enumeration </h4>
<form id="form1" runat="server">
<ASP:DataGrid id="MyDataGrid" runat="server"
Width="900"
BackColor="#ccccff"
BorderColor="black"
ShowFooter="false"
CellPadding="3"
CellSpacing="0"
Font-Names="Verdana"
Font-Size="8pt"
HeaderStyle-BackColor="#aaaadd"
EnableViewState="false"
/>
<i>Page last generated on:</i> <asp:label id="TimeMsg" runat="server" />
</form>
</body>
</html>
설명
이 열거형에 지정된 값은 .aspx 파일에 지시문을 @ OutputCache 포함할 때 사용됩니다. 이러한 값은 페이지 출력의 캐시 위치를 결정합니다. 자세한 내용은 ASP.NET 페이지 캐시 참조하세요.