Trending

World technology news

→
How Alt-Svc changes the connection endpoint while preserving origin identity
Software Engineering · 2016
Software Engineering2016

How Alt-Svc changes the connection endpoint while preserving origin identity

An April 2016 specification, examined through a local example of age and freshness, origin authentication, and fallback to a direct connection.

Archive retrospective · Topic year 2016

Developer's JournalPublished: Dec 6, 20266 min read
Reading progress0%
In this article
  1. One published address with two connection paths
  2. Counting down the lifetime of an advertisement
  3. Four outcomes in a local program
  4. Preserving authority through the endpoint change
  5. Measuring fallback from the reader's perspective
  6. What the 2016 document explains today

One published address with two connection paths

A document catalog opens under journal.example. Its publisher wants to serve the catalog from a nearby endpoint while preserving the address indexed by search engines, the origin of the user session, and links pointing into the site. RFC 7838, published in April 2016, makes those concerns separable. An HTTP origin can advertise a network endpoint and protocol configuration through which a client may obtain its resources. Our example uses reserved domain names and makes no remote connection. The scenario differs from an HTTP redirect that moves the reader to a different URL. The client's connection choice changes, while the resource remains associated with its original URL. That distinction determines what stays stable in the address bar, request logs, and identity checks when a publisher adds or retires an edge endpoint.

Counting down the lifetime of an advertisement

An Alt-Svc advertisement identifies an alternative protocol and authority, with optional parameters. An origin can advertise several choices. If the response arrives through a cache, its existing age counts against the lifetime of the advertisement. Our input allows sixty seconds, the response arrives twelve seconds old, and the local clock reads ten seconds at receipt. Forty-eight seconds remain, so the entry expires when that clock reads fifty-eight seconds. Freshness for the advertised route and freshness for the representation are separate. A page can still be reusable while its preferred route has expired. Keeping observation time and expiry with a route entry makes that distinction visible. The RFC additionally addresses changes of network and clearing advertisements. The example covers one route and the exact expiry boundary.

Application flowConceptual sketch · summary of the article's technical flow
Illustrative diagram: the network address can change while the request retains its origin.

Four outcomes in a local program

A small Node.js program compares four inputs without opening a connection. The first case combines an unexpired route, a reachable endpoint, and successful authentication. It selects edge.example:8443 as the network endpoint and journal.example as the request authority. The second case arrives precisely at expiry and falls back to the origin. The third case represents a peer that cannot establish the original identity, and the fourth represents an unreachable endpoint. Both select the direct route. The program ran on Node.js v24.19.0 and all four assertions passed. It models the selection decision with controlled inputs. It does not parse a real header, perform a TLS handshake, or measure a production CDN. Availability at a port and a valid identity check are different observations.

import assert from 'node:assert/strict';

const now = 58_000;
const learnedAt = 10_000;
const age = 12_000;
const origin = new URL('https://journal.example:443/guides/transport');
const response = { authority: 'edge.example:8443', protocol: 'h2', maxAge: 60_000 };
const expiresAt = learnedAt + Math.max(0, response.maxAge - age);
function candidate(at, certificateMatchesOrigin, alternativeReachable) {
  if (at >= expiresAt || !certificateMatchesOrigin || !alternativeReachable) {
    return { endpoint: origin.host, authority: origin.host, alternative: false };
  }
  return { endpoint: response.authority, authority: origin.host, alternative: true };
}
for (const [label, time, certificate, reachable, alternative] of [
  ['fresh-authenticated', 57_999, true, true, true],
  ['expiry-boundary', now, true, true, false],
  ['wrong-identity', 57_999, false, true, false],
  ['connection-fails', 57_999, true, false, false]
]) {
  const chosen = candidate(time, certificate, reachable);
  assert.equal(chosen.alternative, alternative);
  assert.equal(chosen.authority, 'journal.example');
  console.log(label, chosen.endpoint, chosen.authority);
}

Preserving authority through the endpoint change

Substituting the alternative authority in the request would defeat the catalog's need for a stable resource identity. A client still constructs a request for the original origin and establishes that the alternative is an authorized place to reach it. In the example edge.example describes the connection path. Cookie, permission, and cache decisions associated with the origin continue to use the original identity. Recording the endpoint and request authority separately makes the distinction visible during a rollout. The endpoint answers where the network connection landed. The authority answers which origin’s resource was requested. In a system using a shared edge, conflating those observations can send a diagnosis in the wrong direction. Checking that both paths return equivalent authorization and document results is stronger evidence than seeing both respond to a basic health request.

Measuring fallback from the reader's perspective

A rollout relies on both paths. Early alternative attempts may introduce delay for a fraction of readers, even when the all-traffic average barely moves. A publisher can measure alternative attempts, successful handshakes, direct fallbacks, and end-to-end request latency independently. Representation consistency also matters. If the front ends deploy on different schedules, a reader may see two versions of the same document, depending on the path selected. A stable address solves the naming problem while leaving this consistency problem in view. A short initial advertisement lifetime gives the operator more room to diagnose and correct it. A realistic follow-up test would cover certificate chains, different access networks, and the user-visible result when an alternate endpoint stops responding.

What the 2016 document explains today

RFC 7838 is the historical source for the protocol decision. Today's Node.js runtime is simply the environment for the worked example. It cannot establish which route a particular browser would choose in 2016 or today. Connection reuse, the set of supported protocols, and client policies can all change that choice. Teams can extend their acceptance tests to mobile and desktop clients, separate access networks, and an initial advertisement served from a cache. The user-facing address should remain the same as the connection target varies with freshness, reachability, and identity. Those are the two properties the example isolates. The time it takes a real reader to recover from an unavailable alternative remains a separate operational measurement that needs a real end-to-end test.

761 reads ✎ Write a comment

Reader discussion

Discussion prompt

Which data would you verify before applying this development in your field?

No comments yet. Be the first to contribute.

Write a comment

Comments are real visitor contributions. Repeated, link-heavy or abusive submissions may be limited.