Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Note which browsers only support 103 Early Hints over HTTP/2 or above #24001

Merged
merged 1 commit into from
Jul 31, 2024

Conversation

tunetheweb
Copy link
Contributor

Summary

Chrome and Safari only support 103 Early Hints over HTTP/2 or above.
Firefox supports it over HTTP/1.1 as well though say they might change that - CC: @valenting in case any update here.

This used to be clearly defined in BCD data, but was updated in #21083 and the note about Chrome was removed, and now it only shows a note for Safari under rel=preconnect:

Screenshot of current MDN data showing Safari restricting this to HTTP/2 for preconnect

This is incorrect to me. Chrome has similar restrictions to Safari (for both preconnect and preload), and Safari restricts all of 103, and not just preconnects (though admittedly that is the only type Safari supports so they are kind of equivalent).

So I think this restriction should be under the main 103 entry (rather than just rel=preconnect) and should be the same for Chrome and Safari. Alternatively we can list this restriction under all three entries but that seems a little excessive to me.

Note: I work on Chrome and maintain our docs on this.

Test results and supporting details

This is not covered by WPT that only covers HTTP/2 tests but is easy enough to test with a simple HTTP/1 node server like this that returns a preload:

const net = require('net');

const hostname = '127.0.0.1';
const port = 3000;

const server = net.createServer((socket) => {
  socket.on('data', (data) => {
    const request = data.toString();

    const requestLines = request.split('\r\n');

    const requestLine = requestLines[0];
    const [method, url, protocol] = requestLine.split(' ');

    let response;
    if (method === 'GET' && url === '/') {
      response = `HTTP/1.1 103 Early Hints\r\nLink: </assets/css/common.css>;rel=preload;as=style\r\n\r\nHTTP/1.1 200 OK\r\nContent-Type: text/plain\r\n\r\nWelcome to the homepage!\n`;
    } else {
      response = `HTTP/1.1 404 Not Found\r\nContent-Type: text/plain\r\n\r\n404 Not Found\n`;
    }

    // Write the response to the socket
    socket.write(response);

    // End the connection
    socket.end();
  });

  socket.on('error', (err) => {
    console.error(`Socket error: ${err.message}`);
  });
});

server.listen(port, hostname, () => {
  console.log(`Server running at http://${hostname}:${port}/`);
});

server.on('error', (err) => {
  console.error(`Server error: ${err.message}`);
});

Chrome shows no preload of the CSS file:

image

Neither does Safari (though it doiesn't even support preload early hint so this isn't a great test I admit, but more difficult to show preconnect—and ultimately we're not changing Safari's support here, only Chrome's):

image

But Firefox does:

image

Related issues

Partial reversion of #21083

@github-actions github-actions bot added the data:http 🚠 Compat data for HTTP features. https://developer.mozilla.org/docs/Web/HTTP label Jul 30, 2024
Copy link
Member

@Elchi3 Elchi3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @tunetheweb 👍

@Elchi3 Elchi3 merged commit b24599c into mdn:main Jul 31, 2024
5 checks passed
@valenting
Copy link

FYI Firefox still supports processing 103 over H1.1
Starting with Firefox 129 this behaviour also has a pref but it's still enabled by default.

@tunetheweb
Copy link
Contributor Author

Thanks! Good to know as was curious.

@tunetheweb tunetheweb deleted the 103-http2 branch August 4, 2024 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data:http 🚠 Compat data for HTTP features. https://developer.mozilla.org/docs/Web/HTTP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants