Skip to content

fix: prevent stale chunk errors after deploys#458

Merged
yitianx00 merged 2 commits into
masterfrom
fix/nuxt-chunk-cache-headers
Jul 16, 2026
Merged

fix: prevent stale chunk errors after deploys#458
yitianx00 merged 2 commits into
masterfrom
fix/nuxt-chunk-cache-headers

Conversation

@anilgangapersaud-circle

Copy link
Copy Markdown
Contributor

What

Sets correct HTTP cache headers via Nuxt routeRules:

  • HTML pages: Cache-Control: no-cache — browsers always fetch fresh markup after a deploy
  • /_nuxt/** chunks: Cache-Control: public, max-age=31536000, immutable — safe to cache forever since filenames are content-hashed

Why

After a production deploy, users with cached HTML referencing old chunk hashes would get a Failed to fetch dynamically imported module 500 error. A hard reload fixed it individually, but the correct fix is ensuring HTML is never stale.

Test plan

  • Deploy to sample environment and verify HTML response includes Cache-Control: no-cache
  • Verify /_nuxt/*.js responses include Cache-Control: public, max-age=31536000, immutable
  • Confirm no chunk-load errors after a fresh deploy with cached browser sessions

🤖 Generated with Claude Code

…e headers

HTML pages use no-cache so browsers always fetch fresh markup after a deploy.
Hashed _nuxt/* chunks use immutable long-term caching since their filenames change on every build.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@anilgangapersaud-circle
anilgangapersaud-circle marked this pull request as ready for review July 16, 2026 15:04
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Files

@yitianx00
yitianx00 merged commit f6a08a9 into master Jul 16, 2026
4 checks passed
@yitianx00
yitianx00 deleted the fix/nuxt-chunk-cache-headers branch July 16, 2026 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants