1 preliminary connection
The final resource tip we want to talk about is a preliminary connection. A preliminary connection allows the browser to establish early connections before the HTTP request is actually sent to the server. This includes DNS queries, TLS negotiations, TCP confirmations. This, in turn, eliminates the delay in both directions and saves users time.
2 Prefetch
Prefetching is a low-priority resource hint that allows the browser to retrieve resources in the background (simple) that may be needed later and store them in the browser cache. After the page has finished loading, loading of additional resources begins, and if the user clicks on the previously selected link, he instantly downloads the content.
2.1 Link Preloading
Pre-fetching links allows the browser to retrieve resources and store them in the cache, assuming the user requests them. The browser looks for prefetching in the HTML or HTTP Link header.
2.2 DNS prefetching
DNS prefetching allows the browser to perform DNS lookups on the page in the background while the user is browsing. This minimizes the delay, since a DNS lookup has already occurred when the user clicks on the link. DNS prefetching can be added to a specific URL by adding the rel = "dns-prefetch" tag to the link attribute. We recommend using this for things like Google fonts, Google Analytics, and your CDN.
2.3 Pre-Rendering
Pre-rendering is very similar to pre-fetching in that it collects resources that the user can move on to. The difference is that the preliminary rendering actually displays the entire page in the background, all the resources of the document.
More information: https://www.keycdn.com/blog/resource-hints/
Conclusion
The main difference between dns-prefetch and preconnect
The difference between dns-prefetch and preconnect is that dns-prefetch will only do a DNS lookup, while preconnect will do a DNS lookup, TLS negotiation, and TCP handshake. This means that it avoids the extra 2 RTT when the resource is ready to download.
An important aspect is that dns-prefetch support is much more than preconnect support.
You can find some specific examples here: https://responsivedesign.is/articles/prefetch-preconnect-dns-priority/