v0 performance

Next.js Image Optimization Cache Not Working

Next.js Image component caching isn't working properly. Updated images still show old versions, or image optimization isn't triggered when source images change. Users see stale content.

Image caching issues occur when cache headers aren't properly configured, image paths change unexpectedly, or Vercel's Image Optimization API cache isn't invalidated.

Error Messages You Might See

Image cache not invalidating Stale images being served [Image] Cache control not set Cached image not updating

Common Causes

  1. Using query parameters in image URLs without stable naming (changing URLs prevent caching)
  2. Cache-Control headers set to no-cache or very short expiry for optimized images
  3. Image filename/path changes but URL remains same, serving stale cached version
  4. Dynamic image URLs (different URL for same image) preventing cache hit
  5. Vercel Image Optimization cache not automatically invalidating on deployment

How to Fix It

Use stable URLs: Keep image URLs consistent. If image content changes, include hash in filename: avatar-abc123.jpg

Configure cache headers: In next.config.js, set long cache for optimized images:
headers: async () => [{ source: '/assets/**', headers: [{ key: 'Cache-Control', value: 'public, max-age=31536000, immutable' }] }]

Use Image version parameter: In development, append query string: <Image src={url + '?v=' + Date.now()} /> to bust cache.

Deploy to invalidate: Vercel automatically invalidates image cache on new deployment.

Real developers can help you.

Stanislav Prigodich Stanislav Prigodich 15+ years building iOS and web apps at startups and enterprise companies. I want to use that experience to help builders ship real products - when something breaks, I'm here to fix it. Sage Fulcher Sage Fulcher Hey I'm Sage! Im a Boston area software engineer who grew up in South Florida. Ive worked at a ton of cool places like a telehealth kidney care startup that took part in a billion dollar merger (Cricket health/Interwell health), a boutique design agency where I got to work on a ton of exciting startups including a photography education app, a collegiate Esports league and more (Philosophie), a data analytics as a service startup in Cambridge (MA) as well as at Phillips and MIT Lincoln Lab where I designed and developed novel network security visualizations and analytics. I've been writing code and furiously devoted to using computers to make people’s lives easier for about 17 years. My degree is in making computers make pretty lights and sounds. Outside of work I love hip hop, the Celtics, professional wrestling, magic the gathering, photography, drumming, and guitars (both making and playing them) Luca Liberati Luca Liberati I work on monoliths and microservices, backends and frontends, manage K8s clusters and love to design apps architecture Dor Yaloz Dor Yaloz SW engineer with 6+ years of experience, I worked with React/Node/Python did projects with React+Capacitor.js for ios Supabase expert Daniel Vázquez Daniel Vázquez Software Engineer with over 10 years of experience on Startups, Government, big tech industry & consulting. Mehdi Ben Haddou Mehdi Ben Haddou - Founder of Chessigma (1M+ users) & many small projects - ex Founding Engineer @Uplane (YC F25) - ex Software Engineer @Amazon and @Booking.com Simon A. Simon A. I'm a backend developer building APIs, emulators, and interactive game systems. Professionally, I've developed Java/Spring reporting solutions, managed relational and NoSQL databases, and implemented CI/CD workflows. Rudra Bhikadiya Rudra Bhikadiya I build and fix web apps across Next.js, Node.js, and DBs. Comfortable jumping into messy code, broken APIs, and mysterious bugs. If your project works in theory but not in reality, I help close that gap. Anthony Akpan Anthony Akpan Developer with 8 years of experience building softwares fro startups Krishna Sai Kuncha Krishna Sai Kuncha Experienced Professional Full stack Developer with 8+ years of experience across react, python, js, ts, golang and react-native. Developed inhouse websearch tooling for AI before websearch was solved : )

You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.

Get Help

Frequently Asked Questions

How long should images be cached?

For static images: max-age=1 year (31536000 seconds). For dynamic avatars: max-age=1 day or use version query param.

Why is my updated image still showing old version?

URL is cached. Change filename or add ?v=timestamp to force cache bust. Next.js Image caches based on URL.

Does Vercel Image Optimization cost extra?

Free tier: 1000 optimizations/month. Paid: $0.15 per 10,000 additional. Caching reduces cost.

Related v0 Issues

Can't fix it yourself?
Real developers can help.

You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.

Get Help