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

HTTP 103 Early Hints support #3237

Open
1 task done
junderw opened this issue Feb 26, 2025 · 2 comments
Open
1 task done

HTTP 103 Early Hints support #3237

junderw opened this issue Feb 26, 2025 · 2 comments

Comments

@junderw
Copy link

junderw commented Feb 26, 2025

  • I have looked for existing issues (including closed) about this

Feature Request

Motivation

https://developer.chrome.com/docs/web-platform/early-hints

Early Hints is a method for returning a list of resources to the client before actually sending back the actual response to their query.

This will help with performance on heavier SSR websites.

Proposal

enum EarlyHint {
    Preconnect(String),
    Script(String),
    Style(String),
}
async fn send_early_hint(hints: Vec<EarlyHint>) {
    // ... use tokio::spawn etc. to send off a HTTP 103 Early Hint Response
    // While the body of the handler function (after this await)
    // calls a billion databases to generate the HTML
}

// example
send_early_hint(vec![
    EarlyHint::Style("/main.css".into()),
    EarlyHint::Script("/main.js".into()),
    EarlyHint::Preconnect("https://fonts.google.com".into()),
]).await;
@junderw
Copy link
Author

junderw commented Feb 26, 2025

(This actually feels like something better suited for a proc macro on top of the handler... thoughts?)

@mladedav
Copy link
Collaborator

We'll need hyper support here. There's already some discussion here so you might want to check that out. axum cannot support this until hyper does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants