HttpCapabilitiesBase.SupportsCacheControlMetaTag 属性

定义

获取一个值,该值指示浏览器是否支持 HTML <meta> 元素的 http-equiv 特性的 cache-control 值。

public:
 virtual property bool SupportsCacheControlMetaTag { bool get(); };
public virtual bool SupportsCacheControlMetaTag { get; }
member this.SupportsCacheControlMetaTag : bool
Public Overridable ReadOnly Property SupportsCacheControlMetaTag As Boolean

属性值

Boolean

如果浏览器支持 HTML <meta> 元素的 http-equiv 属性的 cache-control 值,则为 true;否则为 false。 默认值为 true

示例

下面的代码示例演示如何确定浏览器是否支持 cache-control HTML <meta> 元素属性的值http-equiv

<%@ page language="C#"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
    void Page_Load(Object Sender, EventArgs e)
    {
        CheckBrowserCaps();
    }

    void CheckBrowserCaps()
    {
        String labelText = "";
        System.Web.HttpBrowserCapabilities myBrowserCaps = Request.Browser;
        if (((System.Web.Configuration.HttpCapabilitiesBase)myBrowserCaps).SupportsCacheControlMetaTag)
        {
            labelText = "Browser supports the CACHE-CONTROL value for the HTTP-EQUIV attribute of HTML META elements.";
        }
        else
        {
            labelText = "Browser does not support the CACHE-CONTROL value for the HTTP-EQUIV attribute of HTML META elements.";
        }

        Label1.Text = labelText;
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Browser Capabilities Sample</title>
</head>
<body>
    <form runat="server" id="form1">
        <div>
            Browser Capabilities:
            <p/><asp:Label ID="Label1" Runat="server" />
        </div>
    </form>
</body>
</html>
<%@ page language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
    Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        CheckBrowserCaps()
    End Sub

    Function CheckBrowserCaps()

        Dim labelText As String = ""
        Dim myBrowserCaps As System.Web.HttpBrowserCapabilities = Request.Browser
        If (CType(myBrowserCaps, System.Web.Configuration.HttpCapabilitiesBase)).SupportsCacheControlMetaTag Then
            labelText = "Browser supports the CACHE-CONTROL value for the HTTP-EQUIV attribute of HTML META elements."
        Else
            labelText = "Browser does not support the CACHE-CONTROL value for the HTTP-EQUIV attribute of HTML META elements."
        End If

        Label1.Text = labelText

    End Function 'CheckBrowserCaps
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Browser Capabilities Sample</title>
</head>
<body>
    <form runat="server" id="form1">
        <div>
            Browser Capabilities:
            <p/><asp:Label ID="Label1" Runat="server" />
        </div>
    </form>
</body>
</html>

注解

cache-control HTML <meta> 元素属性的值http-equiv允许控制下载内容(包括网页)的客户端缓存。 以下 HTML 片段显示了一个示例:

<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE"/>  

如果,在 true网页元素中包含 <head> 此标记应强制浏览器从服务器重新加载内容。

如果 false,服务器控制适配器会将默认查询字符串追加 (__ufps=``uniquefilepathsuffix) 到还没有链接 URL 值。 这强制浏览器从服务器重新加载内容。

SupportsCacheControlMetaTag 属性也适用于等效的 HTTP 标头形式:

CACHE-CONTROL: NO-CACHE  

适用于