Next.js Discord

Discord Forum

ISR is caching 404 pages, is there a way to prevent this?

Unanswered
Chausie posted this in #help-forum
Open in Discord
ChausieOP
I've setup a new website with ISR caching, but bots and crawlers are fetching random pages that are 404 but still end up getting stored in the next cache increasing memory, is there a way to prevent this?

1 Reply

Elf Owl
Hey! This happens because your dynamic route isn't explicitly throwing a 404 state to the Next.js cache engine. Next.js thinks the bot's random URL is a successful render, so it caches it and eats up your memory. You need to adjust your fallback handling and return states. Shoot me a DM, I can show you how to structure it so it stops caching those dead pages.