Skip to content
Discussion options

You must be logged in to vote

Good question! They serve slightly different purposes:

AddLinkHeadersForPreloadedAssets middleware:

  • Adds HTTP Link headers with rel=preload
  • Browser starts downloading BEFORE parsing HTML
  • Works at HTTP protocol level

Vite's built-in preload:

  • Adds <link rel="modulepreload"> tags in HTML
  • Browser discovers these while parsing <head>
  • Slightly later than HTTP headers

Are they redundant?

Not exactly - HTTP Link headers can give a small performance boost because the browser can start fetching before it even sees the HTML. But honestly, for most apps the difference is negligible.

My recommendation:

  • For simple apps: skip the middleware, Vite's preload is enough
  • For high-traffic apps where ever…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Phucnguyen113
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants