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
Image cache not invalidatingStale images being served[Image] Cache control not setCached 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.

zipking zipking I am a technologist and product builder dedicated to creating high-impact solutions at the intersection of AI and specialized markets. Currently, I am focused on PropScan (EstateGuard), an AI-driven SaaS platform tailored for the Japanese real estate industry, and exploring the potential of Archify. As an INFJ-T, I approach development with a "systems-thinking" mindset—balancing technical precision with a deep understanding of user needs. I particularly enjoy the challenge of architecting Vertical AI SaaS and optimizing Small Language Models (SLMs) to solve specific, real-world business problems. Whether I'm in a CTO-level leadership role or hands-on with the code, I thrive on building tools that turn complex data into actionable value. Vlad Temian Vlad Temian 15+ years shipping production infrastructure for startups. Former CTO at qed.builders (acquired by The Sandbox). Cursor ambassador and agentic tooling builder. I've scaled systems, automated deployments, and built observability tools for AI coding workflows. I specialize in taking vibe-coded apps from broken prototype to production-ready: fixing Supabase auth/RLS, Stripe integrations, deployment pipelines, and cleaning up AI-generated spaghetti. I build tools in this space (agentprobe, claudebin, micode) and understand both sides: how AI generates code and why it breaks. https://blog.vtemian.com/ Victor Denisov Victor Denisov Developer Richard McSorley Richard McSorley Full-Stack Software Engineer with 8+ years building high-performance applications for enterprise clients. Shipped production systems at Walmart (4,000+ stores), Cigna (20M+ users), and Arkansas Blue Cross. 5 patents in retail/supply chain tech. Currently focused on AI integrations, automation tools, and TypeScript-first architectures. 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. Taufan Taufan I’m a product-focused engineer and tech leader who builds scalable systems and turns ideas into production-ready platforms. Over the past years, I’ve worked across startups and fast-moving teams, leading backend architecture, improving system reliability, and shipping products used by thousands of users. My strength is not just writing code — but connecting product vision, technical execution, and business impact. Prakash Prajapati Prakash Prajapati I’m a Senior Python Developer specializing in building secure, scalable, and highly available systems. I work primarily with Python, Django, FastAPI, Docker, PostgreSQL, and modern AI tooling such as PydanticAI, focusing on clean architecture, strong design principles, and reliable DevOps practices. I enjoy solving complex engineering problems and designing systems that are maintainable, resilient, and built to scale. MFox MFox Full-stack professional senior engineer (15+years). Extensive experience in software development, qa, and IP networking. Matthew Jordan Matthew Jordan I've been working at a large software company named Kainos for 2 years, and mainly specialise in Platform Engineering. I regularly enjoy working on software products outside of work, and I'm a huge fan of game development using Unity. I personally enjoy Python & C# in my spare time, but I also specialise in multiple different platform-related technologies from my day job. 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