Unverified Commit e1cb7f74 authored by Sukka's avatar Sukka Committed by GitHub

fix: disable css cache busting in production (#41392)

Continuation of #39664 The PR removes `?ts=` in the production mode.
The corresponding e2e test case is also added.

cc @shuding 
parent 86050df6
...@@ -1184,7 +1184,9 @@ export async function renderToHTMLOrFlight( ...@@ -1184,7 +1184,9 @@ export async function renderToHTMLOrFlight(
? stylesheets.map((href) => ( ? stylesheets.map((href) => (
<link <link
rel="stylesheet" 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 // `Precedence` is an opt-in signal for React to handle
// resource loading and deduplication, etc: // resource loading and deduplication, etc:
// https://github.com/facebook/react/pull/25060 // https://github.com/facebook/react/pull/25060
......
...@@ -264,6 +264,20 @@ describe('app dir', () => { ...@@ -264,6 +264,20 @@ describe('app dir', () => {
expect(html).toContain('hello from app/partial-match-[id]. ID is: 123') 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', () => { describe('rewrites', () => {
// TODO-APP: rewrite url is broken // TODO-APP: rewrite url is broken
it('should support rewrites on initial load', async () => { it('should support rewrites on initial load', async () => {
......
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