Home › Protocols › CDN Protocol Negotiation
Protocols By FlyFish NWA Editorial, CDN Solutions Architect • September 4, 2026 • 9 min read

CDN Protocol Negotiation: ALPN, NPN, and Automatic Protocol Selection

Modern CDNs don’t force a single HTTP version. Instead, they negotiate the optimal protocol — HTTP/1.1, HTTP/2, or HTTP/3 — in milliseconds during the TLS handshake using ALPN. Here’s how it works, why NPN was retired, and how automatic selection impacts performance at the edge.

When a user connects to a CDN edge, both sides support multiple application protocols. The client might speak HTTP/1.1, h2, and h3; the edge might support all three plus origins that only speak HTTP/1.1. Protocol negotiation is the mechanism that picks the best mutual option without extra round trips or failed connections. At scale, getting this right determines whether you benefit from multiplexing, header compression, and 0-RTT, or fall back to legacy behavior.

If you’re new to edge delivery, start with how a CDN works and what a CDN is before tuning protocol settings — negotiation only matters once you understand the TLS termination and caching layer in front of your origin.

1. Why Protocol Negotiation Matters at the CDN Edge

Unlike origin servers, a CDN must serve a wildly heterogeneous fleet: Chrome on HTTP/3, Safari on HTTP/2, legacy bots on HTTP/1.1, and IoT devices with limited TLS stacks. Hard-coding a protocol would break compatibility or waste performance.

Negotiation solves three edge-specific problems:

This is also where caching strategies intersect with protocols: a single HTTP/2 or HTTP/3 connection can fetch dozens of cached assets in parallel, improving cache hit utilization and reducing origin load compared to six parallel HTTP/1.1 connections.

2. NPN: The SPDY-Era Predecessor

Next Protocol Negotiation (NPN) was introduced by Google around 2010 to negotiate SPDY — the precursor to HTTP/2. NPN worked, but with a critical flaw: the server sent its list of supported protocols after the TLS handshake completed, in an unencrypted ServerHello extension.

Performance Comparison: Edge vs Origin Processing
Metric Edge Processing Origin Processing Improvement
Latency (p50)8–15 ms120–300 ms15–20x faster
Cache Hit Ratio85–95%N/AReduces origin load
TLS Handshake1–5 ms (nearby PoP)50–150 ms10–30x faster
Bandwidth Cost$0.01–0.04/GB$0.05–0.12/GB3–5x cheaper
Availability99.99% (multi-PoP)99.9% (single DC)10x fewer outages

That design created two issues. First, middleboxes that inspected TLS could block or strip the extension. Second, it added complexity for strict TLS 1.3 implementations. The IETF deprecated NPN in favor of ALPN (RFC 7301) in 2014, and all major browsers removed NPN support by 2016.

You’ll still see NPN in legacy OpenSSL logs or old Nginx configs (ssl_protocols with npn). If you do, treat it as technical debt. Modern CDNs, including Cloudflare, Fastly, Akamai, and AWS CloudFront, exclusively use ALPN. There is no performance reason to keep NPN enabled, and it can trigger handshake failures with TLS 1.3-only clients.

3. ALPN: How It Works Inside the TLS Handshake

Application-Layer Protocol Negotiation (ALPN) moves negotiation into the TLS handshake. It’s elegant because it adds zero round trips.

Here’s the exact flow at a CDN edge:

  1. ClientHello + ALPN Extension: The client sends a TLS ClientHello listing supported application protocols in priority order, e.g., h3, h2, http/1.1. This is sent in cleartext but within the TLS handshake.
  2. Edge Selection: The CDN edge (e.g., Nginx, Envoy, or custom Rust stack) compares the client list against its own supported list and origin health. It selects the most performant mutual protocol.
  3. ServerHello + ALPN: The edge returns its choice in the ServerHello ALPN extension, e.g., h2.
  4. Encrypted Application Data: All subsequent data is sent using the negotiated protocol. For h3, the edge will also send an Alt-Svc: h3=":443"; ma=86400 header to advertise QUIC for the next connection.

ALPN identifiers are strict strings registered with IANA: h2 for HTTP/2 over TLS, http/1.1 for HTTP/1.1, and h3 for HTTP/3 (though h3 is technically negotiated via QUIC’s TLS 1.3 + Alt-Svc, many CDNs still echo h3 in ALPN for consistency).

ALPN Negotiation Flow at CDN Edge Client sends ClientHello with ALPN h3, h2, http/1.1 to CDN edge, edge selects h2 and returns ServerHello with ALPN h2 CLIENT (Browser) h3, h2, http/1.1 CDN EDGE (PoP) Supports h2, http/1.1 ClientHello + ALPN: h3, h2, http/1.1 ServerHello + ALPN: h2 ✓ TLS 1.3 Handshake Complete Application Data over HTTP/2 — multiplexed + Alt-Svc: h3=":443" for next connection
Figure 1: ALPN negotiation inside the TLS handshake — no extra round trip. If UDP is reachable, the next connection upgrades to h3 via Alt-Svc.

Because ALPN is part of the handshake, it’s visible in packet captures and openssl s_client output. That makes debugging straightforward compared to NPN’s post-handshake dance.

4. Automatic Protocol Selection: How CDNs Choose

ALPN tells the edge what the client supports. Automatic selection decides what to use based on a policy engine. Most CDNs follow this hierarchy:

4.1 Client Preference + Edge Capability

The edge intersects the client’s ALPN list with its own. If the client offers h2, http/1.1 and the edge supports both, it picks h2. If the client is a legacy crawler offering only http/1.1, the edge honors it — no upgrade attempt.

4.2 Network Conditions and QUIC Fallback

HTTP/3 over QUIC uses UDP. Some corporate firewalls block UDP 443. A smart CDN won’t force h3 on first contact. Instead, it completes the first connection over h2, advertises Alt-Svc, and lets the browser probe QUIC in parallel. If QUIC succeeds, the next connection uses h3 with 0-RTT. If it times out, the browser stays on h2. This is why you’ll see h3 in ALPN but actual h3 usage at ~65-85% depending on geography.

4.3 Origin Protocol Compatibility

The viewer-facing protocol is independent from the origin-facing one. A CDN can terminate h3 at the edge and proxy to origin over h2 or HTTP/1.1 keep-alive. This is configured via origin protocol policy. For dynamic APIs where load balancing algorithms spread requests across origins, keeping origin connections as HTTP/1.1 or h2 avoids QUIC’s UDP complexity inside the data center.

Edge tip: Enable “Automatic” or “Negotiate” mode at your CDN and avoid forcing “HTTP/2 only.” Forcing breaks roughly 0.3-0.8% of traffic from old Java clients, corporate proxies, and health checkers that only speak HTTP/1.1.

5. Performance Impact: Does Negotiation Cost You?

Measured overhead is negligible, but the choice has major performance consequences:

When evaluating cost vs. speed, remember that fewer connections also mean lower cost optimization impact — fewer edge CPU cycles for handshakes and better cache coalescing.

FeatureNPN (Deprecated)ALPN (Standard)HTTP/3 / Alt-Svc
StandardDraft (Google), never IETFRFC 7301 (IETF)RFC 9114 + RFC 9000 (QUIC)
Negotiation timingAfter handshake (encrypted)Inside ClientHello/ServerHelloAfter first h2/h1.1 via Alt-Svc header
Extra round trips0, but post-handshake00 for upgrade; 1 probe for QUIC
TLS versionTLS 1.0–1.2 onlyTLS 1.2 and 1.3TLS 1.3 inside QUIC
Firewall traversalPoor (unencrypted ext.)ExcellentRequires UDP 443 open
Browser supportRemoved 2016All modern browsersChrome 87+, Firefox 88+, Safari 14+
CDN use todayNone — disabledDefault for h2 negotiationOpportunistic upgrade to h3

6. Configuring and Debugging Protocol Negotiation

You rarely configure ALPN directly on a CDN — it’s automatic. But you should verify it and tune origins.

Verify ALPN from the edge

# Check what ALPN protocol was negotiated (h2 vs http/1.1)
openssl s_client -connect cdn.example.com:443 -alpn h2,http/1.1 -servername cdn.example.com </dev/null 2>&1 | grep ALPN

# Expected: ALPN protocol: h2

# Test HTTP/3 advertisement
curl -I https://cdn.example.com --http2
# Look for: alt-svc: h3=":443"; ma=86400

Origin configuration (Nginx example)

If you terminate TLS at origin or use “Full Strict” mode, ensure your origin advertises ALPN correctly:

# /etc/nginx/nginx.conf — requires OpenSSL 1.0.2+
server {
  listen 443 ssl http2;
  ssl_certificate /etc/ssl/cert.pem;
  ssl_certificate_key /etc/ssl/key.pem;
  ssl_protocols TLSv1.2 TLSv1.3;
  ssl_alpn h2 http/1.1; # explicit ALPN list
}

# Verify origin ALPN
curl --http2 -v https://origin.example.com/ 2>&1 | grep ALPN

Common pitfalls

For a broader architecture view, review CDN fundamentals to see where negotiation fits between DNS, TLS, and caching.

Conclusion

NPN proved that protocol negotiation was necessary; ALPN proved how to do it cleanly inside the TLS handshake. Today, automatic protocol selection at the CDN edge means you don’t choose between compatibility and performance — the edge negotiates h2 for multiplexing, upgrades to h3 when QUIC is reachable, and falls back to http/1.1 when needed, all without extra latency.

Leave negotiation on automatic, verify with openssl s_client and curl -v, and ensure your origin supports ALPN with a modern OpenSSL build. The result is fewer connections, faster page loads, and a future-proof edge ready for HTTP/3 ubiquity.

Frequently Asked Questions

What is the difference between ALPN and NPN?

NPN was Google’s pre-standard protocol that advertised supported protocols after the TLS handshake. ALPN (RFC 7301) sends the client’s protocol list inside the ClientHello and the server’s choice inside ServerHello, making it encrypted, firewall-friendly, and compatible with TLS 1.3. NPN was deprecated in 2016 and should be disabled.

Does ALPN add latency to the CDN handshake?

No. ALPN is piggybacked on the existing TLS handshake and adds only a few bytes with zero additional round trips. CDNs use it to negotiate h2, http/1.1, or h3 instantly. The performance win comes from the selected protocol itself, not the negotiation.

How does a CDN automatically choose between HTTP/1.1, HTTP/2, and HTTP/3?

The edge intersects the client’s ALPN list with its own capabilities and picks the highest mutually supported protocol. For HTTP/3, it first serves over h2 and sends an Alt-Svc header; the browser then probes QUIC over UDP. If the probe succeeds, subsequent connections use h3 with 0-RTT, otherwise it stays on h2.

Do I need to configure ALPN on my origin?

Usually not. The CDN handles ALPN at the edge where viewers connect. You only need origin ALPN if you use end-to-end TLS with HTTP/2 to origin or require protocol validation. In that case, ensure Nginx/Apache and OpenSSL 1.1.1+ are configured with ssl_alpn h2 http/1.1 and keep http/1.1 for health checks.

External References

References & Standards: OWASP CDN Security · HTTP/2 specification