Next.js Discord

Discord Forum

Sitemap indefinitely cached Vercel (Next.js 13 app router)

Unanswered
Oak shoot sawfly posted this in #help-forum
Open in Discord
Oak shoot sawflyOP
I have a sitemap.ts that makes a fetch call to a CMS to get pages to show in the sitemap. The fetch call has a cache tag associated with it that is revalidated.

However, my sitemap is not getting new pages that are added to the CMS. All other cache revalidation tags work, but the sitemap one specifically does not. Rebuilding and deploying does update the sitemap.

I have seen others having similar issues, but couldn't find an answer. Is there a fix or approach for this?

6 Replies

Oak shoot sawflyOP
export const dynamic = 'force-dynamic'; on the sitemap file works, but then I'm missing out on cache entirely
Oak shoot sawflyOP
Explicitly setting export const revalidate = 60 also works, but it's not ideal. It would be better to revalidate the sitemap on demand using cache tags like I've used elsewhere as it would reduce calls to my CMS and also keep the sitemap up-to-date rather than 60 seconds
Oak shoot sawflyOP
That seems to work. Any idea why revalidating the path would work but revalidating the tag for the fetch doesn't? Does Next have some specific path level caching for sitemap?
you may want to report a bug