nextjs - ✅(Solved) Fix next/image in dev does not update local image after file edit with same filename [1 pull requests]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Fix Action

Fix / Workaround

Workarounds:

  • rename the image file
  • delete .next and restart next dev

PR fix notes

PR #93082: fix(image): include file mtime in dev-mode cache key for local public/ images

Description (problem / solution / changelog)

What?

In development, next/image caches optimised images keyed by href + width + quality + mimeType. When a developer edits an image in public/ without renaming it the cache key stays the same, so the optimiser never re-runs and the browser keeps serving the stale image until .next is deleted.

Why?

ImageOptimizerCache uses minimumCacheTTL (default 14400 s) so entries remain fresh for hours regardless of whether the source file changed on disk.

How?

When the dev server handles a non-absolute, non-static (i.e. public/ sourced) image request, stat the underlying file and mix its mtimeMs into the cache key. If the file has changed, the new key misses the cache → the image is re-optimised and the updated version is served on the very next request.

The stat is wrapped in try/catch so the code silently falls back to the original key for dynamic image routes, images that cannot be found on disk, or any other error case.

No changes to public API, types, or the production code path.

Fixes #93075

Changed files

  • packages/next/src/server/next-server.ts (modified, +21/-1)

Code Example

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.3.0: Wed Jan 28 20:54:22 PST 2026; root:xnu-12377.81.4~5/RELEASE_ARM64_T8112
  Available memory (MB): 16384
  Available CPU cores: 8
Binaries:
  Node: 24.14.1
  npm: 11.11.0
  Yarn: 1.22.22
  pnpm: 10.33.0
Relevant Packages:
  next: 16.2.4 // Latest available version is detected (16.2.4).
  eslint-config-next: N/A
  react: 19.2.5
  react-dom: 19.2.5
  typescript: N/A
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/Austin1serb/next.js-minimal-build

To Reproduce

  1. Clone the reproduction repo.
  2. Install dependencies.
  3. Start the app in development mode with next dev.
  4. Open the page in the browser.
  5. The page renders the same local image twice, once with next/image and once with a plain <img>.
  6. Edit the source image file used by both elements without changing its filename.
  7. Refresh the page.
  8. The plain <img> shows the updated image, but next/image still shows the old image.
  9. Rename the image file or delete .next and restart the dev server.
  10. next/image then shows the updated image.

Current vs. Expected behavior

Expected: Both next/image and plain <img> should reflect the updated local file in development after the image contents change.

Current: Only the plain <img> updates. next/image continues to show a stale version when the file contents change but the filename stays the same.

Workarounds:

  • rename the image file
  • delete .next and restart next dev

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.3.0: Wed Jan 28 20:54:22 PST 2026; root:xnu-12377.81.4~5/RELEASE_ARM64_T8112
  Available memory (MB): 16384
  Available CPU cores: 8
Binaries:
  Node: 24.14.1
  npm: 11.11.0
  Yarn: 1.22.22
  pnpm: 10.33.0
Relevant Packages:
  next: 16.2.4 // Latest available version is detected (16.2.4).
  eslint-config-next: N/A
  react: 19.2.5
  react-dom: 19.2.5
  typescript: N/A
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Image

Which stage(s) are affected? (Select all that apply)

next dev

Additional context

This is specifically about local development. The reproduction shows a difference between next/image and plain <img> using the same local source image.

extent analysis

TL;DR

The issue can be worked around by deleting the .next directory and restarting the development server, or by renaming the image file.

Guidance

  • The likely cause is a caching issue with next/image in development mode, where it fails to update when the image file contents change but the filename remains the same.
  • To verify, try updating the image file and refreshing the page; if next/image still shows the old image, the issue is likely related to caching.
  • To mitigate, delete the .next directory and restart the development server, or rename the image file to force next/image to reload the updated image.
  • Consider checking the next configuration for any caching settings that may be contributing to the issue.

Example

No code snippet is provided as the issue is related to the behavior of next/image in development mode, and the reproduction repository is already available.

Notes

This issue appears to be specific to local development with next dev, and the workarounds provided should help resolve the issue in the short term. However, it may be worth investigating whether there are any configuration options or updates to next that can permanently resolve the caching issue.

Recommendation

Apply workaround: deleting the .next directory and restarting the development server, or renaming the image file, as these methods have been confirmed to resolve the issue in the provided reproduction repository.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

nextjs - ✅(Solved) Fix next/image in dev does not update local image after file edit with same filename [1 pull requests]