浏览器是否始终加载apple-touch-icons?

时间:2014-07-24 10:48:49

标签: html hyperlink apple-touch-icon

我想这个问题的答案是一个很大的问题,但是,为了确定,我在这里问:

<link rel="apple-touch-icon*这样的图标是否总是由浏览器加载(我的意思是,也不是iOS浏览器)?

2 个答案:

答案 0 :(得分:4)

否。浏览器仅在首次加载时加载Apple Touch图标。

测试此协议的协议:我在RealFaviconGenerator的帮助下创建了两个页面(完全披露:我是本网站的作者),几乎相同,并通过Apache提供。 page1.html包含:

<html>
    <head>
        <link rel="apple-touch-icon" sizes="57x57" href="/apple-touch-icon-57x57.png">
        <link rel="apple-touch-icon" sizes="114x114" href="/apple-touch-icon-114x114.png">
        <link rel="apple-touch-icon" sizes="72x72" href="/apple-touch-icon-72x72.png">
        <link rel="apple-touch-icon" sizes="144x144" href="/apple-touch-icon-144x144.png">
        <link rel="apple-touch-icon" sizes="60x60" href="/apple-touch-icon-60x60.png">
        <link rel="apple-touch-icon" sizes="120x120" href="/apple-touch-icon-120x120.png">
        <link rel="apple-touch-icon" sizes="76x76" href="/apple-touch-icon-76x76.png">
        <link rel="apple-touch-icon" sizes="152x152" href="/apple-touch-icon-152x152.png">
        <link rel="icon" type="image/png" href="/favicon-196x196.png" sizes="196x196">
        <link rel="icon" type="image/png" href="/favicon-160x160.png" sizes="160x160">
        <link rel="icon" type="image/png" href="/favicon-96x96.png" sizes="96x96">
        <link rel="icon" type="image/png" href="/favicon-16x16.png" sizes="16x16">
        <link rel="icon" type="image/png" href="/favicon-32x32.png" sizes="32x32">
        <meta name="msapplication-TileColor" content="#2b5797">
        <meta name="msapplication-TileImage" content="/mstile-144x144.png">
    </head>
    <body>
        <h1>Page 1</h1>
    </body>
</html>

page2.html与具有不同h1的{​​{1}}相同。

然后,我访问了page1.html,然后访问了page2.html并检查了Apache的日志以检查HTTP访问。这是我发现的。

Windows Chrome 36.0.1985.125 m

导航至第1页

"GET /page1.html HTTP/1.1" 200 662 "-" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36"
"GET /favicon-32x32.png HTTP/1.1" 304 179 "-" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36"
"GET /favicon-16x16.png HTTP/1.1" 304 179 "-" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36"

导航至第2页

"GET /page2.html HTTP/1.1" 200 662 "-" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36"

因此Chrome会在首次加载时加载一些favicons,但在访问引用相同图片的其他页面时不会再次加载图标。

Android Chrome 36.0.1.1985.128

导航至第1页

"GET /page1.html HTTP/1.1" 200 662 "-" "Mozilla/5.0 (Linux; Android 4.4.2; SM-G900F Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.128 Mobile Safari/537.36"
"GET /favicon-160x160.png HTTP/1.1" 200 5703 "-" "Mozilla/5.0 (Linux; Android 4.4.2; SM-G900F Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.128 Mobile Safari/537.36"
"GET /apple-touch-icon-144x144.png HTTP/1.1" 200 9889 "-" "Mozilla/5.0 (Linux; Android 4.4.2; SM-G900F Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.128 Mobile Safari/537.36"

导航至第2页

"GET /page2.html HTTP/1.1" 200 662 "-" "Mozilla/5.0 (Linux; Android 4.4.2; SM-G900F Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.128 Mobile Safari/537.36"

同样的行为。

iOS7 Safari

导航至第1页

"GET /page1.html HTTP/1.1" 200 662 "-" "Mozilla/5.0 (iPad; CPU OS 7_1 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Version/7.0 Mobile/11D167 Safari/9537.53"

换句话说,Safari在浏览时不会加载任何图标。这是有道理的:它不会在界面中显示任何图标。

点击&#34;分享&#34;按钮

(显示&#34;添加到主屏幕&#34;选项)

"GET /apple-touch-icon-152x152.png HTTP/1.1" 200 10313 "-" "MobileSafari/9537.53 CFNetwork/672.1.13 Darwin/14.0.0"

绝对有道理。

导航至第2页

"GET /page2.html HTTP/1.1" 200 662 "-" "Mozilla/5.0 (iPad; CPU OS 7_1 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Version/7.0 Mobile/11D167 Safari/9537.53"

点击&#34;分享&#34;按钮

什么都没发生。再次,这是正常的,图标已经加载。

Android Firefox 31.0

导航至第1页

"GET /page1.html HTTP/1.1" 200 662 "-" "Mozilla/5.0 (Android; Mobile; rv:31.0) Gecko/31.0 Firefox/31.0"
"GET /favicon-196x196.png HTTP/1.1" 200 13393 "-" "Mozilla/5.0 (Android; Mobile; rv:31.0) Gecko/31.0 Firefox/31.0"

导航至第2页

"GET /page2.html HTTP/1.1" 200 662 "-" "Mozilla/5.0 (Android; Mobile; rv:31.0) Gecko/31.0 Firefox/31.0"

答案 1 :(得分:2)

没有。浏览器不会遵循他们不认识的链接类型。