OutputCacheLocation 列挙型

定義

ある応答に対する出力キャッシュの HTTP 応答の場所を制御する有効な値を指定します。

public enum class OutputCacheLocation
public enum OutputCacheLocation
type OutputCacheLocation = 
Public Enum OutputCacheLocation
継承
OutputCacheLocation

フィールド

Any 0

出力キャッシュは、ブラウザー クライアント (要求の送信元)、要求に参加しているプロキシ サーバー (または他の任意のサーバー)、または要求が処理されたサーバーに配置できます。 この値は、Public 列挙値に対応します。

Client 1

出力キャッシュは、要求の送信元のブラウザー クライアントに配置されます。 この値は、Private 列挙値に対応します。

Downstream 2

出力キャッシュは、送信元サーバー以外のすべての HTTP 1.1 キャッシュ対応デバイスに格納できます。 これには、プロキシ サーバーおよび要求を出したクライアントも含まれます。

None 4

出力キャッシュは、要求されたページに対して無効です。 この値は、NoCache 列挙値に対応します。

Server 3

出力キャッシュは、要求の処理元の Web サーバーに配置されます。 この値は、Server 列挙値に対応します。

ServerAndClient 5

出力キャッシュは、元のサーバーまたは要求側のクライアントにだけ格納されます。 プロキシ サーバーは応答をキャッシュすることはできません。 この値は、Private 列挙値と Server 列挙値の組み合わせに対応します。

次のコード例は、サーバー値を使用して、要求が処理される Web サーバーにページをキャッシュするように指定する方法を示しています。

<%@ 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 ページのキャッシュ」を参照してください。

適用対象

こちらもご覧ください