dns prefetch / pre-resolve hostname - how effective?

后端 未结 1 2030
無奈伤痛
無奈伤痛 2020-12-23 16:51

I\'ve been reading up on how this works but am struggling to make sense of it.

From what I can tell if I set

相关标签:
1条回答
  • 2020-12-23 17:14

    In the first case, DNS pre-fetching will not help as you are loading the same resource on each page. The resource should be cached on subsequent requests, so pre-fetching the dns record won't have any effect.

    In the second case, simply removing and adding the link element is not sufficient to test the effect of prefetching. Even without the link element, the browser will scan hrefs to determine which domains to prefetch - the link tag is meant to tell it to prefetch a domain in addition to those the browser would find - this is useful in the case where you know a link to one domain is ultimately redirected to another.

    One way to see the effect of the prefetch tag would be to set up a few sites. www.example.com/index.html would contain a link to www.anotherexample.com which would, in turn, redirect to www.athirdsite.com. If you were to test this configuration with and without a link tag pointing to www.athirdsite.com, you may see that it is faster with the link tag. You are far more likely to see this effect if the nameserver in use has high latency.

    In closing, I'd simply let the browser do its thing unless you have a very particular reason for instructing it to do something else in addition.

    0 讨论(0)
提交回复
热议问题