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

fix: disable css cache busting in production #41392

Merged
merged 2 commits into from Oct 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/next/server/app-render.tsx
Expand Up @@ -1184,7 +1184,9 @@ export async function renderToHTMLOrFlight(
? stylesheets.map((href) => (
<link
rel="stylesheet"
href={`/_next/${href}?ts=${Date.now()}`}
// 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()}` : ''}`}
// `Precedence` is an opt-in signal for React to handle
// resource loading and deduplication, etc:
// https://github.com/facebook/react/pull/25060
Expand Down
14 changes: 14 additions & 0 deletions test/e2e/app-dir/index.test.ts
Expand Up @@ -264,6 +264,20 @@ describe('app dir', () => {
expect(html).toContain('hello from app/partial-match-[id]. ID is: 123')
})

// This is a workaround to fix https://github.com/vercel/next.js/issues/5860
// TODO: remove this workaround when https://bugs.webkit.org/show_bug.cgi?id=187726 is fixed.
it('should use cache busting when loading css (dev only)', async () => {
const html = await renderViaHTTP(next.url, '/')
const $ = cheerio.load(html)
const links = $('link[rel=stylesheet]')
links.each((_, link) => {
const href = $(link).attr('href')
isDev
? expect(href).toMatch(/\?ts=/)
: expect(href).not.toMatch(/\?ts=/)
})
})

describe('rewrites', () => {
// TODO-APP: rewrite url is broken
it('should support rewrites on initial load', async () => {
Expand Down