1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Implement preconnect to reduce latency for modern browsers

Discussion in 'XenForo Suggestions' started by Mouth, Dec 20, 2015.

  1. Mouth

    Mouth Well-Known Member

    The preconnect relation is used to indicate an origin that will be used to fetch required resources. Initiating an early connection, which includes the DNS lookup, TCP handshake, and optional TLS negotiation, allows the user agent to mask the high latency costs of establishing a connection.

    To initiate a preconnect, the user agent must run these steps:

    1. Resolve the URL given by the href attribute.
      1. If that is successful, let preconnect URL be the resulting absolute URL, and otherwise abort these steps.
      2. If preconnect URL's scheme is not one of "http" or "https" then abort these steps.
    2. Let origin be preconnect URL's origin.
    3. Let corsAttributeState be the current state of the element's crossorigin content attribute.
    4. Let credentials be a boolean value set to true.
    5. If corsAttributeState is Anonymous and origin is not equal to current Document's origin, set credentials to false.
    6. Attempt to obtain connection with origin and credentials.
    The user agent should attempt to initiate a preconnect and perform the full connection handshake (DNS+TCP for HTTP, and DNS+TCP+TLS for HTTPS origins) whenever possible, but is allowed to elect to perform a partial handshake (DNS only for HTTP, and DNS or DNS+TCP for HTTPS origins), or skip it entirely, due to resource constraints or other reasons.

    The optimal number of connections per origin is dependent on the negotiated protocol, users current connectivity profile, available device resources, global connection limits, and other context specific variables. As a result, the decision for how many connections should be opened is deferred to the user agent.

    Ref: http://w3c.github.io/resource-hints/#preconnect
    Sunka and rafass like this.

Share This Page