Migration Guide: HTTP/1.1 to HTTP/2

Step-by-step guide for migrating from HTTP/1.1 to HTTP/2. Covers TLS setup, server configuration, removing HTTP/1.1 workarounds, and testing verification.

Adoption

Detailed Explanation

Migrating from HTTP/1.1 to HTTP/2

Migrating to HTTP/2 is one of the easiest performance wins for most websites. The protocol is backward-compatible, universally supported, and requires minimal application changes.

Prerequisites

  1. TLS is required: All browsers require HTTPS for HTTP/2. If you are still serving HTTP, set up TLS first.
  2. TLS 1.2 or later: HTTP/2 requires TLS 1.2+ with ALPN support.
  3. Modern server software: Nginx 1.9.5+, Apache 2.4.17+, Caddy (any version), Node.js 8.4+.

Server Configuration

Nginx:

server {
    listen 443 ssl http2;
    ssl_certificate /path/to/cert.pem;
    ssl_certificate_key /path/to/key.pem;
    ssl_protocols TLSv1.2 TLSv1.3;
}

Apache:

Protocols h2 h2c http/1.1

Caddy: HTTP/2 is enabled by default with automatic TLS.

Remove HTTP/1.1 Workarounds

After enabling HTTP/2, remove these optimizations that become counterproductive:

  1. Domain sharding: Multiple subdomains to bypass connection limits. HTTP/2 uses one connection — sharding adds DNS lookups and prevents connection reuse.
  2. Image sprites: Combining images into one file. Individual images are more efficient with multiplexing and have better caching.
  3. CSS/JS concatenation: Merging all scripts into one file. Smaller files cache independently and load in parallel.
  4. Inlining: Embedding CSS/JS in HTML. Separate files can be cached and shared across pages.

Testing

  1. Open Chrome DevTools > Network tab
  2. Right-click the column headers and enable "Protocol"
  3. Load your page — look for "h2" in the protocol column
  4. Verify that all resources load correctly

Common Pitfalls

  • Forgetting ALPN: Without ALPN, the browser cannot negotiate HTTP/2 during the TLS handshake
  • Proxy interference: If a reverse proxy does not support HTTP/2, it may downgrade connections
  • Connection coalescing: HTTP/2 may reuse a connection for different hostnames sharing the same IP and certificate

Use Case

Website operators still using HTTP/1.1 should migrate to HTTP/2 as a first step. The performance improvement is immediate and requires no application code changes. Teams that have already optimized for HTTP/1.1 with domain sharding and concatenation should plan to remove those workarounds after migration.

Try It — HTTP/2 vs HTTP/3 Comparison

Open full tool