DNS预取和页面优化 [英] DNS prefetching and page optimization

查看:184
本文介绍了DNS预取和页面优化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天我在网页的HTML源代码中看到这个代码片段:

Today I saw this snippet in the HTML source of a webpage:

<!-- prefetch dns -->
<link rel="dns-prefetch" href="//s3.amazonaws.com">
<link rel="dns-prefetch" href="//cdn.api.twitter.com">
<link rel="dns-prefetch" href="//graph.facebook.com">
<link rel="dns-prefetch" href="//connect.facebook.net">
<link rel="dns-prefetch" href="//api.pinterest.com">
<link rel="dns-prefetch" href="//google-analytics.com">

这样做可以获得多少?我以前没看过,也没有在 Yahoo!开发人员网络优化指南。唯一似乎相关的是减少DNS查找。

How much can you gain by doing this? I haven't seen this before, nor in the Yahoo! Developer Networks guidelines for optimization. The only thing that seems related is "Reduce DNS Lookups".

以类似的方式,为什么这些服务不会向他们的服务公开IP地址,并完全避免DNS查找?

In a similar fashion, why doesn't these services expose an IP address to their services and avoid the DNS look-up altogether?

推荐答案

我想这可以让这些链接的并行DNS查找后来用于一堆JavaScript。

I guess that this gives parallel DNS lookup of those links later used for a bunch of JavaScript's.

CDN的直接IP数字不正常。他们解决给靠近呼叫者的主机。如果你在美国,他们会在美国给你一台服务器的IP。如果你在欧洲,他们会在欧洲给你一个服务器的IP等等。你不能用直接的IP号码欺骗。

Direct IP-numbers does not work well with CDN's. They resolve to a host close to the caller. If you are in the US they give you the IP of a server in US. If you are in Europe they give you the IP of a server in Europe, etc. You can't cheat like that with direct IP numbers.

这篇关于DNS预取和页面优化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆