Next.js Discord

Discord Forum

How to handle ISR cache when self hosting?

Unanswered
American Crocodile posted this in #help-forum
Open in Discord
American CrocodileOP
Hi, I host a next.js (Pages) site that has a lot of user generated pages on AWS. I have a couple of issues around my ISR pages I'm not sure how to deal with.

Note, I don't build all the pages at build time because there are too many, it's too slow and it takes up about 30gb.

1. If I erase the existing .next/server/pages contents on the server before deploying, all pages need to be recalculated (even if no change) so navigating is slower for each page on the first attempt
2. If I don't erase the .next/server/pages contents and there is a change to the html design, the old page will be served with potentially broken html/navigation.

I'm considering only deleting the .html files but potentially changes to json content could also be an issue. Maybe I need a way to specific when and what to delete based at deployment time based on the changelist.

I'm also considering the approach of switching to SSR and using cloudfront to cache but this feels like it might be susceptible to the same issue of serving broken content.

What approach is recommended for large numbers of quite big pages.

Thanks!

1 Reply

American CrocodileOP
Hi - any one able to advise on this? thanks