Unverified Commit 7182d4dd authored by Shu Ding's avatar Shu Ding Committed by GitHub

Always add `?ts=` query for scripts during development (#53411)

Safari caches scripts during the same browsing session no matter what cache headers are set. This makes it impossible to update our runtime bundles (e.g. Webpack's runtime) during development as the legacy bundle might be cached and still served. If an updated client bundle uses a feature (e.g. `__webpack_require__.n`) that causes a change of the runtime, it triggers an error.

The most straightforward solution would be adding a query to prevent caching.

Fixes #53281.
parent caf5ee80
...@@ -1583,14 +1583,20 @@ export async function renderToHTMLOrFlight( ...@@ -1583,14 +1583,20 @@ export async function renderToHTMLOrFlight(
src: src:
`${assetPrefix}/_next/` + `${assetPrefix}/_next/` +
src + src +
getAssetQueryString(false), // Always include the timestamp query in development
// as Safari caches them during the same session, no
// matter what cache headers are set.
getAssetQueryString(true),
integrity: subresourceIntegrityManifest[src], integrity: subresourceIntegrityManifest[src],
})) }))
: buildManifest.rootMainFiles.map( : buildManifest.rootMainFiles.map(
(src) => (src) =>
`${assetPrefix}/_next/` + `${assetPrefix}/_next/` +
src + src +
getAssetQueryString(false) // Always include the timestamp query in development
// as Safari caches them during the same session, no
// matter what cache headers are set.
getAssetQueryString(true)
)), )),
], ],
}, },
......
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