🎉 Requestly joins BrowserStack to build the future of application testing. Read more

HTTP Headers

Alt Svc

HTTP Header

The HTTP Alt-Svc response header allows a server to specify an alternate network location, known as the “alternative service,” which can be considered authoritative for that origin for future requests.
This mechanism enables servers to advertise new protocol versions without disrupting ongoing requests and aids in traffic management. Using an alternative service happens transparently to the end user; it does not alter the URL or request origin and does not add extra round-trip communications.

Syntax

http
Alt-Svc: clear
Alt-Svc: <protocol-id>=<alt-authority>; ma=<max-age>
Alt-Svc: <protocol-id>=<alt-authority>; ma=<max-age>; persist=1

Directives

The following describes the components and options of the Alt-Svc header used in HTTP communications:

clear
This option invalidates all alternative services associated with the origin, effectively clearing any cached alternative service entries.
<protocol-id>
The identifier for the Application-Layer Protocol Negotiation (ALPN) protocol. Common examples include h2 for HTTP/2 and h3-25 indicating draft 25 of the HTTP/3 protocol. This helps clients and servers agree on the protocol to use for communication.
<alt-authority>
A quoted string that specifies an alternative authority, which may include an optional host override, a colon, and a mandatory port number. This allows directing traffic to an alternative server or port.
ma=<max-age> Optional
This parameter indicates how many seconds the alternative service can be considered fresh. If not specified, it defaults to 24 hours. The client can cache the alternative service entry for up to <max-age> seconds, minus the age of the response (taken from the Age header). Once this period expires, the client must stop using this alternative for new connections.
persist=1 Optional
Including this parameter ensures that the cached alternative service entries survive network configuration changes. Typically, network resets or configuration modifications clear cached entries, but persist=1 prevents that from happening.

Multiple Alt-Svc entries can be specified in a single header by separating each with a comma. Preferring entries earlier in the list allows for more optimal route selection.

Example

Alt-Svc: h2=":443"; ma=2592000;
Alt-Svc: h2=":443"; ma=2592000; persist=1
Alt-Svc: h2="alt.example.com:443", h2=":443"
Alt-Svc: h3-25=":443"; ma=3600, h2=":443"; ma=3600

How to Modify Header using Requestly

Requestly is a powerful Chrome extension that allows you to modify HTTP headers, including the Alt-Svc header. This is especially useful for testing how your application handles alternative service advertisements and network protocol preferences. Steps to Modify the Alt-Svc Header:

  1. Install and open the Requestly Chrome extension. You can find it on the Chrome Web Store.
  2. Create a new rule: Click on “Create Rule” and choose “Modify Headers” from the list of available rule types.
  3. Add a new header modification:
    • Under “Action”, select “Add” or “Override”.
    • In the “Header Name” field, enter Alt-Svc.
    • In the “Header Value” field, enter the desired alternative service information (e.g., h3=”:443″; ma=3600).
  4. Set the URL condition: Specify the URL or pattern where this header change should apply (e.g., https://your-api.com/*).
  5. Save the rule.

Once set up, Requestly will inject the specified Alt-Svc header into all matching requests, allowing you to simulate and test how your server and client react to alternative service announcements.

Modifying the Alt-Svc header helps you test network protocol optimizations or troubleshoot connectivity issues by simulating different alternative service settings without changing server configuration.