Skip to content

FR: preconnect() and prefetchDns() APIs #48

Description

@passcod

🤖 Browsers act on <link rel="preconnect"> and <link rel="dns-prefetch">; fáith can expose the same verbs on the agent:

  • agent.prefetchDns(host) — resolve and warm the DNS cache.
  • agent.preconnect(origin) — resolve DNS and open a connection ahead of the first request, so it skips 1–3 RTTs of setup.

The eager-probe machinery from #45 is most of the HTTP/3 half of the implementation: preconnect to an origin with a known/advertised h3 endpoint is "kick the probe now". The TCP side would want an equivalent H/1/2 probe — cheap (a pooled connection warm-up, or a HEAD over TCP), but worth building at the same time so preconnect() means the same thing regardless of which protocol the origin ends up on.

Semantics to pin down in design: what preconnect promises (connection open? just attempted?), whether it returns a promise that settles on establishment, and how it interacts with pool idle timeouts (a preconnected socket that idles out before use bought nothing).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions