HttpCachePolicy.SetValidUntilExpires(Boolean) Metódus
Definíció
Fontos
Egyes információk olyan, kiadás előtti termékekre vonatkoznak, amelyek a kiadásig még jelentősen módosulhatnak. A Microsoft nem vállal kifejezett vagy törvényi garanciát az itt megjelenő információért.
Megadja, hogy a ASP.NET gyorsítótár figyelmen kívül hagyja-e a HTTP-Cache-Control a gyorsítótárat érvénytelenítő ügyfél által küldött fejléceket.
public:
void SetValidUntilExpires(bool validUntilExpires);
public void SetValidUntilExpires(bool validUntilExpires);
member this.SetValidUntilExpires : bool -> unit
Public Sub SetValidUntilExpires (validUntilExpires As Boolean)
Paraméterek
- validUntilExpires
- Boolean
trueha a gyorsítótár figyelmen kívül hagyja az Cache-Control érvénytelenítés fejléceit; ellenkező esetben. false
Példák
Az alábbi példakód bemutatja, hogyan utasíthatja a metódust arra SetValidUntilExpires , hogy az ügyfél által küldött gyorsítótár-érvénytelenítési fejlécek figyelmen kívül legyenek hagyva.
<!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>
Megjegyzések
A SetValidUntilExpires módszer automatikusan true a magas szintű <%@ OutputCache … %> oldalirányelvet használja.
Ez a módszer azért van megadva, mert egyes böngészők oldalnézet frissítésekor http-gyorsítótár érvénytelenítési fejléceket küldenek a webkiszolgálónak, és kiürítik a lapot a gyorsítótárból. Ha a validUntilExpires paraméter true, ASP.NET figyelmen kívül hagyja a gyorsítótár érvénytelenítési fejléceit, és a lap a gyorsítótárban marad, amíg lejár.
SetValidUntilExpires a .NET-keretrendszer 3.5-ös verziójában kerül bevezetésre. További információ: Verziók és függőségek.