Skip to content
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

Merged
merged 3 commits into from Oct 10, 2022

Conversation

danielroe
Copy link
Member

πŸ”— Linked issue

unjs/nitro#439

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to 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:

curl -D - http://localhost:3000

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

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@danielroe danielroe added enhancement New feature or request nitro 🍰 p2-nice-to-have Priority 2: nothing is broken but it's worth addressing performance labels Sep 28, 2022
@danielroe danielroe requested a review from pi0 September 28, 2022 12:14
@danielroe danielroe self-assigned this Sep 28, 2022
@codesandbox
Copy link

codesandbox bot commented Sep 28, 2022

CodeSandbox logoCodeSandbox logoΒ  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

@netlify
Copy link

netlify bot commented Sep 28, 2022

βœ… Deploy Preview for nuxt3-docs canceled.

Name Link
πŸ”¨ Latest commit 55ff9dd
πŸ” Latest deploy log https://app.netlify.com/sites/nuxt3-docs/deploys/63343b2b7483c70008edf52f

@danielroe danielroe mentioned this pull request Oct 9, 2022
@danielroe danielroe requested a review from Atinux October 10, 2022 10:55
@danielroe danielroe merged commit 5a2616c into main Oct 10, 2022
@danielroe danielroe deleted the perf/early-hints branch October 10, 2022 11:02
@danielroe danielroe added the 3.x label Jan 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
3.x enhancement New feature or request nitro 🍰 p2-nice-to-have Priority 2: nothing is broken but it's worth addressing performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants