Preconnect is an important tool for optimization which can eliminate many costly roundtrips from request path. W3C has Resource Hints Specification. That includes preconnect, preload, prefetch, and prerender. We Have Developed Preconnect WordPress Plugin, Which is a Free Software available in GitHub. We have modified WordPress DNS Prefetch plugin for this purpose. Preconnect includes DNS Prefetch itself. Preconnect allows the browser to setup early connections even before an HTTP request is sent. Preconnect includes DNS lookups, TLS negotiations, TCP handshakes which in turn, eliminates roundtrip latency and saves time for users. Domain Preconnect is important for HSTS websites (like that of us).
Understanding Domain Preconnect WordPress Plugin (rel preconnect)
Domain Preconnect WordPress Plugin is available on GitHub, click here to visit that webpage (webpage will open in new tab).
Instructions and details are written there. After activating the plugin, you’ll get Preconnect as an option under settings (in WordPress Admin panel). You’ll tick to activate it and add the domains you want to add. You need to carefully add the domains adjusting with performance on webpagetest. Obviously, each open socket incurs costs and unused must be avoided.
---
You will get the W3C Resource Hints Specification here :
1 | https://www.w3.org/TR/resource-hints/ |
From that resource, for reconnect :
The full resource URL may not be known until the page is being constructed by the user agent – e.g. conditional loading logic, UA adaptation, etc. However, the origin from which one or more of these resources will be fetched is often known ahead of time by the developer or the server generating the response. In such cases, a preconnect hint can be used to initiate an early connection handshake such that when the resource URL is determined, the user agent can dispatch the request without first blocking on connection negotiation.
Here is an infographics :
Domain Preconnect WordPress Plugin with KeyCDN : Optimization Guide
It is not recommended to use more than 4 URLs for the purpose. If you are using KeyCDN (you may try the free trial of KeyCDN from here) with HSTS website, set different Zones for Javascript, CSS, Images etc. Images of illustration are by KeyCDN, they did lot of research on it. If you preconnect all, over 20 URLs may decrease the performance of the user’s browser. Try to check the waterfall on webpagetest and selective add domains. KeyCDN or Akamai will not have huge latency, but Google’s CDN’s are of pathetic quality. They possibly use a custom version of Nginx as web server.
We suggest to use own subdomain with SSL/TLS certificate from GeoTrust and use Dyn DNS to resolve it, then point towards KeyCDN.