Skip to content
Latchkey

Vercel/Netlify build cache stale after deploy in CI

The deploy shipped old output because a cached build step was reused when it should have rebuilt. A cache keyed too loosely, or a framework build cache that did not invalidate, produces stale assets in the deployment.

What this error means

A deploy succeeds but serves the previous build: new code is present in the repo yet the deployed bundle is unchanged. Clearing the cache and redeploying produces the correct output.

CI cache
Restored build cache from key: build-cache
# build step reports "no changes, reusing cached output"
# deployed bundle matches the previous release, not the new commit

Common causes

A build cache key that ignores source changes

The cache key hashes only lockfiles or a fixed string, so it hits even when application source changed, and the old build output is restored.

A framework cache not invalidated on config change

The framework build cache (Next.js, etc.) is reused across an env or config change that should have forced a rebuild.

How to fix it

Key the cache on the build inputs

  1. Include source and lockfile hashes in the cache key so source changes miss the cache.
  2. Restrict what is cached to dependencies, not built output, when output must be fresh.
  3. Redeploy and confirm the new bundle ships.
.github/workflows/ci.yml
- uses: actions/cache@v4
  with:
    path: node_modules
    key: deps-${{ hashFiles('**/package-lock.json') }}
    # do NOT cache the build output directory when it must rebuild

Force a clean build when needed

Clear the provider build cache (or disable it for the run) so the deploy rebuilds from source.

Terminal
# Vercel: skip the remote build cache for this deploy
npx vercel deploy --prod --force --token=${VERCEL_TOKEN} --yes

How to prevent it

  • Key caches on source and lockfile hashes, not a static string.
  • Cache dependencies, not build output that must be fresh each deploy.
  • Provide a way to force a clean rebuild when a deploy looks stale.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →