fix: include deployment id in the webpack cache key - #1980
Draft
marcleblanc2 wants to merge 1 commit into
Draft
marcleblanc2 wants to merge 1 commit into
marcleblanc2 wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
next/font bakes Vercel's ?dpl= skew-protection query into the CSS url()s at build time, but Next's webpack cache key does not include the deployment id. With the restored .next/cache the CSS keeps the previous deployment's id while the HTML preloads use the new one, so every font downloads twice.
marcleblanc2
force-pushed
the
marc/fix/webpack-cache-deployment-id
branch
from
September 17, 2026 02:32
852c1f6 to
e75ec8b
Compare
Contributor
Author
|
From the docs site audit (crawl of all 502 pages). Crawl evidence for the double font download: on 403 of 502 pages every font was fetched twice (~110 KB wasted, preloads unused), because the CSS was served under one |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Every font downloads twice in production. The HTML preloads fonts with
?dpl=<current deploy>, but the CSSurl()s carry the previous deployment'sdpl, so the browser sees two URLs per font (verified live withcurlon the CSS chunk vs the HTML).Cause:
next/fontbakes Vercel's skew-protection?dpl=into the CSS at build time via thedeploymentIdloader option, but Next's webpack filesystem cache key (webpack-config.js, theconfigVarsblob) does not includedeploymentId. Vercel restores.next/cache, so the cached CSS module is re-emitted with the old id.Fix
A
webpack()hook innext.config.jsappendsNEXT_DEPLOYMENT_IDtoconfig.cache.version, so each deployment gets a fresh webpack cache.Tradeoffs
dplquery at all. Worth considering since this is a static docs site.deploymentIdtoconfigVars; happy to file that if wanted.Verification
Reproduced and fixed locally with back-to-back builds on a warm
.next/cache:dplafter build 2dpldpl_test123dpl_test456dpl_test456✅dpl_test456dpl_test789dpl_testABCdpl_test789❌dpl_testABCAfter the production deploy:
curl -s https://sourcegraph.com/docs/_next/static/css/<hash>.css | grep -o 'dpl_\w*' | sort -ushould match thedplin the page HTML.