HttpCachePolicy.SetValidUntilExpires(Boolean) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
ASP.NET 캐시가 캐시를 무효화하는 클라이언트에서 보낸 HTTP Cache-Control 헤더를 무시해야 하는지 여부를 지정합니다.
public:
void SetValidUntilExpires(bool validUntilExpires);
public void SetValidUntilExpires(bool validUntilExpires);
member this.SetValidUntilExpires : bool -> unit
Public Sub SetValidUntilExpires (validUntilExpires As Boolean)
매개 변수
- validUntilExpires
- Boolean
true 캐시가 무효화 헤더를 무시하면 Cache-Control 이고, false그렇지 않으면 .
예제
다음 코드 예제에서는 클라이언트에서 보낸 캐시 무효화 헤더가 무시 되도록 지시 하는 메서드를 사용 SetValidUntilExpires 하는 방법을 보여 줍니다.
<!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>
설명
SetValidUntilExpires 상위 수준 true 페이지 지시문을 사용할 때 메서드가 자동으로 설정 <%@ OutputCache … %> 됩니다.
일부 브라우저에서 페이지 보기를 새로 고치는 경우 HTTP 캐시 무효화 헤더를 웹 서버로 보내고 캐시에서 페이지를 제거하기 때문에 이 메서드가 제공됩니다.
validUntilExpires 매개 변수가 true 경우 ASP.NET 캐시 무효화 헤더를 무시하고 페이지가 만료될 때까지 캐시에 유지됩니다.
SetValidUntilExpires .NET Framework 버전 3.5에 도입되었습니다. 자세한 내용은 버전 및 종속성을 참조하세요.