Unverified Commit 85f7d4b3 authored by Sukka's avatar Sukka Committed by GitHub

perf(#41392): improve cache busting inject performance (#41443)

The PR continues from #41392.

In #41392 the `dev ? cache-busting : empty` is executed per stylesheet instead of per page rendering. Since rendering link tags would be a hot path at the server, it might have accidentally introduced a performance overhead. The PR fixes that.

Note, this change also makes `Date.now()` only execute once instead of per stylesheets, however, this will most likely not cause any issues.
parent 482e3fbf
......@@ -1165,6 +1165,10 @@ export async function renderToHTMLOrFlight(
Component: () => {
let props = {}
// Add extra cache busting (DEV only) for https://github.com/vercel/next.js/issues/5860
// See also https://bugs.webkit.org/show_bug.cgi?id=187726
const cacheBustingUrlSuffix = dev ? `?ts=${Date.now()}` : ''
return (
<>
{preloadedFontFiles.map((fontFile) => {
......@@ -1184,9 +1188,7 @@ export async function renderToHTMLOrFlight(
? stylesheets.map((href) => (
<link
rel="stylesheet"
// Add extra cache busting (DEV only) for https://github.com/vercel/next.js/issues/5860
// See also https://bugs.webkit.org/show_bug.cgi?id=187726
href={`/_next/${href}${dev ? `?ts=${Date.now()}` : ''}`}
href={`/_next/${href}${cacheBustingUrlSuffix}`}
// `Precedence` is an opt-in signal for React to handle
// resource loading and deduplication, etc:
// https://github.com/facebook/react/pull/25060
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment