This repository has been archived by the owner on Apr 6, 2023. It is now read-only.
perf(nitro): respond with early hints in node-based environments #7893
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
π Linked issue
unjs/nitro#439
β Type of change
π Description
This PR adds support for rendering Early Hints in node-based servers. We could also consider locating this elsewhere (e.g. in nitropack: unjs/nitro#439), but the particular hints we want to render are very tied to the specifics of the Nuxt renderer, and not easily portable. Thoughts/suggestions welcome.
I have opened a PR to refactor L104 -> h3 (unjs/h3#184), where it may also be used in userland (e.g. nitro middleware or plugins). If merged, we can refactor this PR to use the same utility.
If you want to test this, build the app and run:
It's only currently supported in Chrome 103+, and you'll need to be on a newer protocol than HTTP/1.1 to see it in action.
We currently render the headers per-request, which takes less than 1ms (tests ranged from 0.3ms -> 0.9ms). I've opened a PR in vue-bundle-renderer in case we want to statically render them to string when the renderer is created, as a further optimisation (nuxt-contrib/vue-bundle-renderer#40), but this may be unnecessary.
π Checklist