HttpCachePolicy.SetValidUntilExpires(Boolean) Methode

Definition

Gibt an, ob der ASP.NET-Cache Cache-Control-HTTP-Header ignorieren sollte, die vom Client gesendet wurden, der den Cache für ungültig erklärt.Specifies whether the ASP.NET cache should ignore HTTP Cache-Control headers sent by the client that invalidate the cache.

public:
 void SetValidUntilExpires(bool validUntilExpires);
public void SetValidUntilExpires (bool validUntilExpires);
member this.SetValidUntilExpires : bool -> unit
Public Sub SetValidUntilExpires (validUntilExpires As Boolean)

Parameter

validUntilExpires
Boolean

true, wenn der Cache ungültige Cache-Control-Header ignoriert, andernfalls false.true if the cache ignores Cache-Control invalidation headers; otherwise, false.

Beispiele

Im folgenden Codebeispiel wird veranschaulicht, wie die SetValidUntilExpires -Methode verwendet wird, um anzuweisen, dass alle vom Client gesendeten Cache-invalidierungsheader ignoriert werden.The following code example demonstrates how to use the SetValidUntilExpires method to instruct that any cache invalidation headers sent by the client are ignored.

<!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" >
<head>
    <title>ASP.NET Example</title>
<script language="C#" runat="server">

// The following example demonstrates the SetValidUntilExpires method of the
// HttpCachePolicy class. The SetValidUntilExpires method is set to true so 
// that the ASP.NET cache ignores the HTTP Cache-Control headers and the page 
// remains in the cache until it expires.

void Page_Load(object Sender, EventArgs e)
{
   // Set the expiration time for the page.
   Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));
   // Set the VaryByHeaders attribute with the value Accept-Language to true.
   Response.Cache.VaryByHeaders["Accept-Language"] = true;
   // ASP.NET ignores cache invalidation headers and the page remains in 
   // the cache until it expires.
   Response.Cache.SetValidUntilExpires(true);
   Response.Write("The SetValidUntilExpires method is set to true and ASP.NET cache should " + 
      "ignore the Cache-Control headers sent by the client that invalidate the cache.");
}

</script>
</head>
<body></body>
</html>
<!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" >
<head>
    <title>ASP.NET Example</title>
<script language="VB" runat="server">

' The following example demonstrates the SetValidUntilExpires method of the
' HttpCachePolicy class. The SetValidUntilExpires method is set to true so that
' the ASP.NET cache ignores the HTTP Cache-Control headers and the page remains 
' in the cache until it expires.

Sub Page_Load(Sender As Object, e As EventArgs)
   ' Set the expiration time for the page.
   Response.Cache.SetExpires(DateTime.Now.AddSeconds(60))
   ' Set the VaryByHeaders attribute with the value Accept-Language to true.
   Response.Cache.VaryByHeaders("Accept-Language") = True
   ' ASP.NET ignores cache invalidation headers and the page remains in
   ' the cache until it expires.
   Response.Cache.SetValidUntilExpires(True)
   Response.Write("The SetValidUntilExpires method is set to true and the ASP.NET cache will " _
      & " ignore the Cache-Control headers sent by the client that invalidate the cache.")
End Sub 'Page_Load

</script>
</head>
<body></body>
</html>

Hinweise

Die SetValidUntilExpires -Methode wird automatisch true auf festgelegt, <%@ OutputCache … %> wenn die allgemeine Seiten Direktive verwendet wird.The SetValidUntilExpires method is set to true automatically when the high-level <%@ OutputCache … %> page directive is used.

Diese Methode wird bereitgestellt, da einige Browser beim Aktualisieren einer Seitenansicht HTTP-Cache-Ungültigkeits Header an den Webserver senden und die Seite aus dem Cache entfernen.This method is provided because some browsers, when refreshing a page view, send HTTP cache invalidation headers to the Web server and evict the page from the cache. Wenn der validUntilExpires -Parameter trueist, ignoriert ASP.net die Cache-Invalidierung-Header, und die Seite bleibt im Cache, bis Sie abläuft.When the validUntilExpires parameter is true, ASP.NET ignores cache invalidation headers and the page remains in the cache until it expires.

SetValidUntilExpireswird in der .NET Framework Version 3,5 eingeführt.SetValidUntilExpires is introduced in the .NET Framework version 3.5. Weitere Informationen finden Sie unter Versionen und Abhängigkeiten.For more information, see Versions and Dependencies.

Gilt für: