Learn about how Cloudflare supports HTTP/2 and HTTP/3 to speed up your website without requiring changes to your existing codebase.
HTTP/2 and HTTP/3 accelerate page load and are free for all Cloudflare plans. HTTP/2 is enabled by default and requires an SSL certificate at Cloudflare’s edge network. Configure HTTP/2 and HTTP/3 via the Cloudflare Network app.
A browser and web server automatically negotiate the highest protocol available. Thus, HTTP/3 takes precedence over HTTP/2. Cloudflare only uses HTTP/1.x between the origin web server and Cloudflare.
To determine the protocol used for your connection, enter example.com/cdn-cgi/trace from a web browser or client and replace example.com with your domain name. Several lines of data are returned. If http=h2 appears in the results, the connection occurred over HTTP/2. Other possible values are http=http2+quic/99 for HTTP/3, and http=http/1.x for HTTP/1.x.
HTTP/2 improves page load times via:
- Connection multiplexing - Retrieves multiple resources in a single network request. Responses are sent when resources are available to avoid slowing page rendering.
- HTTP header compression - Compresses headers and simplifies HTTP requests to avoid resending headers.
- HTTP/2 Server Push - To improve page load speed, Cloudflare provides additional resources for a client to cache without waiting for additional requests.
- Not all browsers support HTTP/2 and use HTTP 1.x instead.
- Connection multiplexing is on a per-domain basis.
HTTP/3 enables fast, reliable, and secure connections. HTTP/3 encrypts Internet transport by default using a protocol from Google called QUIC. Enable HTTP/3 via the Cloudflare Network app. Use the following methods to experiment with HTTP/3:
To use Chrome to connect to your website over HTTP/3, first download and install the latest Canary build. Then, enable HTTP/3 support in Chrome Canary using the --enable-quic and --quic-version=h3-23 command-line arguments.
Once Chrome starts, type your domain in the address bar. Check the protocol version via the Network tab in Chrome’s Developer Tools. If http2+quic/99 doesn’t appear in the Protocol column when connecting to your domain, try reloading the page.
For macOS, use Homebrew to install cURL with HTTP/3 support:
brew install --HEAD -s https://raw.githubusercontent.com/cloudflare/homebrew-cloudflare/master/curl.rb
Then, perform an HTTP/3 cURL with the --http3 command-line flag:
./curl -I https://blog.cloudflare.com/ --http3
Confirm HTTP/3 appears in the response and that there were no error messages.
git clone --recursive https://github.com/cloudflare/quiche
Next build the code with a working Rust and Cargo installation. Set up a working Rust development environment using rustup.
cargo build --examples
Finally, execute an HTTP/3 request:
RUST_LOG=info target/debug/examples/http3-client https://<yourwebsite.com>/
Server Push extracts URI references within the rel=preload parameter of the Link header from your origin server. These additional URIs are then provided to the client. Example Link headers include:
Link: </images/image.png>; rel=preload;
Link: </css/main.css>; rel=preload;
Server Push is limited to 50 assets per page and 100 per connection.
Browser support information: