Preview Browser Serves Stale Client-Side JavaScript Despite Full Cache Clear
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
The Claude Code Preview browser (preview_* MCP tools) persistently serves stale/cached client-side JavaScript bundles even after fully stopping the server, deleting the .next build cache, and restarting.
I edited a React client component (changed button text, CSS classes, and layout structure). The source file, TypeScript compilation, and SSR compiled output all confirmed the new code — but the preview browser kept rendering the OLD version.
Tried all of the following with no success:
preview_stop→rm -rf .next→preview_start(multiple times)location.reload(true)(hard reload)- Clearing Service Workers and Cache API via
preview_eval - Cache-busting query parameters (
?nocache=timestamp) touchon the source file to trigger HMR
The embedded browser's internal cache appears to survive across server stop/start cycles and cannot be cleared by any available method.
What Should Happen?
After stopping the preview server and restarting it (especially after deleting the build cache), the preview browser should serve fresh content with no stale JavaScript bundles.
Ideally, one of the following should exist:
- A
preview_clear_cachetool to explicitly flush the browser cache - Automatic cache clearing when
preview_stopis called - A
clearCache: trueoption onpreview_start - A fresh browser profile/context for each
preview_startinvocation
Error Messages/Logs
No error messages — the issue is silent. The browser renders without errors but with outdated content.
Evidence of mismatch:
Source file (correct):
className: "rounded border px-2 py-1.5"
button text: {gun} (number only)
SSR compiled output (.next/) (correct):
grep confirms "rounded border px-2 py-1.5" present
grep confirms old class "rounded-lg border px-2 py-1" NOT present
Browser DOM via preview_eval (stale):
className: "rounded-lg border px-2 py-1" ← OLD
button text: "1 gün", "3 gün" ... ← OLD
Environment: macOS, Next.js 16.1.6 (Turbopack), Claude Code latest
Steps to Reproduce
- Create a Next.js 16 project with a
"use client"component - Start the dev server via
preview_start - Navigate to a page that renders the component and verify via
preview_screenshot - Edit the client component (e.g., change CSS class from
rounded-lgtorounded, change button text) - Stop the server via
preview_stop - Delete the build cache:
rm -rf .next - Restart the server via
preview_start - Navigate to the same page and verify via
preview_eval/preview_screenshot
Result: The browser still renders the OLD component code. The SSR compiled output in .next/ contains the correct new code, but the browser DOM shows stale classes and text.
Tried additionally: location.reload(true), clearing Service Workers, clearing Cache API, cache-busting query params, touch source file — none resolved it.
Claude Model
Not sure / Multiple models
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.63 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
Suggested Fix
At minimum, one of the following would resolve this:
- A
preview_clear_cachetool to explicitly flush the embedded browser's disk/code cache - Automatic cache clearing when
preview_stopis called - A
clearCache: trueoption onpreview_start - Use a fresh browser profile/context for each
preview_startinvocation
Key Observation
The issue specifically affects client-side hydration bundles. Server-side rendered output
(verified via grep on .next/dev/server/chunks/ssr/*.js) is always correct and up-to-date.
The stale code only appears in the browser's client-side JavaScript execution, suggesting
the embedded Chromium's V8 code cache or disk cache is not being invalidated.
Impact
This makes iterative UI development with preview_screenshot unreliable. Once a component
is first rendered in the preview browser, subsequent code changes may never be visually
verifiable — forcing developers to rely solely on source code inspection and TypeScript
compilation for verification.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗