Next.js Discord

Discord Forum

Static page and not-found being cached

Unanswered
Weevil parasitoid posted this in #help-forum
Open in Discord
Weevil parasitoidOP
Using the App directory, I have a /link/[id]/page.tsx that is returning some page that takes 1/2s to generate.

For perceived speed reason, this link URL is optimistically created on the client side which means a user can visit /link/[id] before the page is "ready".

Once generated, those pages will never change so I take advantage of the Incremental Static Generation for very fast render.

If the page is not ready, I render a data will be ready soon div.

The issue is then that some users can open the URL too early and this data will be ready soon is cached for ever.

I also tried to use notfound() instead assuming that nextjs wouldn't cache a page that throws but it seems to be the case. Clearing cache/incognito mode will forever return the not found page although the page is now ready.

Also worth mentioning that the page isn't cached locally in dev mode (I made sure there was no hot-reload or changes) so it doesn't behave the same way as in prod.

Is there a way to prevent caching until the resources for my page are ready?

Thanks!

0 Replies