DNS Prefetch DNS预解析

今天在支付宝的页面代码看到


  
<link href="https://a.alipayobjects.com" rel="dns-prefetch" />
<link href="https://app.alipay.com" rel="dns-prefetch" />
<link href="https://my.alipay.com" rel="dns-prefetch" />
<link href="https://lab.alipay.com" rel="dns-prefetch" />
<link href="https://cashier.alipay.com" rel="dns-prefetch" />
<link href="https://financeprod.alipay.com" rel="dns-prefetch" />
<link href="https://shenghuo.alipay.com" rel="dns-prefetch" />
查了下dns prefetch的用处,在这里做个标记以备后用


什么是 DNS Prefetch ? 

DNS Prefetch 是一种 DNS 预解析技术。当你浏览网页时,浏览器会在加载网页时对网页中的域名进行解析缓存,这样在你单击当前网页中的连接时就无需进行 DNS 的解析,减少用户等待时间,提高用户体验。

目前每次DNS解析,通常在200ms以下。针对DNS解析耗时问题,一些浏览器通过DNS Prefetch 来提高访问的流畅性。 

设置方式

如果要浏览器端对特定的域名进行解析,通过以下两种方式实现:

1、通过 link 标签实现,例如:< link rel="dns-prefetch" href="http://api.twitter.com" />

2、通过 meta 标签实现,例如:< meta http-equiv="x-dns-prefetch-control" content="on" />

3、通过设置 Http header 的 x-dns-prefetch-control 属性为 on 进行控制。 

这段代码应尽量写在网页的前部,起到减少dns请求的功能。

浏览器支持

  • Firefox: 3.5+
  • Chrome: Supported
  • Safari 5+
  • IE: 9

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值