AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Next/Image In Dev Does Not Update Local Image After File Edit With Same Filename

In Next.js development mode, the image optimizer caches by URL only. When a local image file's contents change but the filename stays the same, the cached optimized image is served stale. This affects only next/image, while a plain <img> tag with the same source updates correctly.

mediumConfidence 85%Next.jsnext buildReact Server ComponentsApp RouterAffected V16.2.4

Origin Analysis

The image optimization endpoint caches results using a key derived solely from the upstream URL, width, and quality, without incorporating file modification time or content hash. Since the URL remains unchanged when the file content changes, the cache returns the old image.
1. Clone the reproduction repo at https://github.com/Austin1serb/next.js-minimal-build. 2. Run `npm install` and then `npm run dev`. 3. Open the page that renders the same local image using both `next/image` and a plain `<img>`. 4. Edit the source image file (e.g., change its pixel content) without changing its filename. 5. Refresh the browser page. 6. Observe that the plain `<img>` shows the updated image, but `next/image` still displays the old version.

Fixing Code Block

// next.config.js module.exports = { images: { // Disable image optimization in development to avoid stale cache for local files unoptimized: process.env.NODE_ENV === 'development', }, }
Setting `images.unoptimized` to true in development bypasses the image optimization pipeline entirely, serving the original file directly. This eliminates the stale cache because the browser uses normal HTTP caching for the static file, which revalidates based on file changes. In production, optimization remains enabled.

Edge Case Audit

This workaround disables image optimization in development, which means no automatic resizing, compression, or format conversion. It may affect performance profiling if you rely on optimized images during development. To roll back, remove the `unoptimized` flag or set it to false. If you still need optimization in dev, consider clearing the `.next/cache/images` directory on file changes or restarting the dev server. The root cause remains unfixed in Next.js core.

Ecosystem Topology

Agent Frameworks

LangChain, LlamaIndex, and Pydantic

  1. highProperty graph relation keys collide when entity IDs or labels contain underscores
  2. highCodeActAgent drops assistant tool-call metadata during handoff, leaving an orphan tool response
  3. high[Bug]: HierarchicalNodeParser async methods return the documents unsplit
  4. highLLM.predict_and_call fails with ValidationError for non-function-calling models when react_chat_formatter is omitted
  5. highAnthropic streaming server-tool input_json_delta overwrites completed client tool_use arguments due to stale cur_tool_call state