Back to feed
Dev.to
Dev.to
7/29/2026
Next.js Sitemap Not Updating? Here's the Real Fix

Next.js Sitemap Not Updating? Here's the Real Fix

Short summary

A detailed debugging guide for a Next.js sitemap cache-coherence bug where revalidateTag invalidates inner data cache but leaves the outer route handler's statically rendered XML untouched. The fix is a single line—export const revalidate = 3600—forcing the sitemap route to re-render on a bounded interval. The article also explains a broader principle: revalidateTag clears data, not the route that renders it, so any stacked cache requires either route-level revalidate or revalidatePath.

  • Sitemap staleness caused by dual-layer caching: unstable_cache invalidated but route handler output remains frozen
  • Fix: add export const revalidate = 3600 to sitemap.ts for route-level ISR
  • Broader rule: revalidateTag clears data, not the route; always set route-level revalidate or call revalidatePath

Generated with AI, which can make mistakes.

Is this a good recommendation for you?

Comments

Failed to load comments. Please try again.

Explore more