Next.js Discord

Discord Forum

How to invalidate cache of the homepage of a Next.js site?

Answered
Muscovy Duck posted this in #help-forum
Open in Discord
Muscovy DuckOP
I just migrated an old website to a Next.js 13.4.19 site.
I am surprised to see many 404 in my logs and suspect that the homepage is cached in many users browsers.

Is there a way to set cache to Cache-Control: no-cache, no-store, max-age=0, must-revalidate for only the / route? (app folder)
Answered by aardani
export const dynamic = 'force-dynamic' on your /app/page.jsx
View full answer

7 Replies

Muscovy DuckOP
Answer
Muscovy DuckOP
Ohh nice, seems to be doing the trick, thanks a lot!
Muscovy DuckOP
There is a bug issue with this with next-sitemap: it emptied my sitemap-0.xml I have no idea why.
If I remove the export const dynamic = 'force-dynamic' line from layout.tsx page, I have the js error in Search Console errors
Any idea how to solve this?