Hey everyone, I’m stuck with a problem on my Next.js e-commerce site. It’s pretty big, with about 10,000 products. I want all the product pages to be static, but I’m not sure how to do it right.
I tried using Incremental Static Regeneration, but it’s not working well with my setup. Every time I restart or redeploy, all the pre-built pages disappear. That’s not good for users.
Building all pages at once takes way too long. I was thinking maybe I could make static pages slowly after each build, like over a few hours.
Oh, and I need to update pages when the backend changes stuff too.
Anyone know a good way to do this? I’m using a self-hosted setup, if that matters. Any tips or tools would be super helpful. Thanks!
yo boldpainter45, that’s a big site! have u tried static site generators like gatsby or hugo? they can handle lots of pages. or maybe use a headless CMS with nextjs? that way u can update content easily. also, check out netlify or vercel for easy deploys and automatic builds. good luck with ur project!
For a large-scale Next.js e-commerce site with 10,000 products, consider implementing a staged static generation approach. Initially, generate static pages for your top-selling or most viewed products during the build process. This ensures critical pages are immediately available.
For the remaining products, utilize a background job system that gradually generates static pages post-deployment. This can be achieved using a queue system and serverless functions, allowing you to generate pages over time without impacting site performance.
Implement a robust caching strategy using a CDN to serve static content efficiently. Additionally, set up webhooks or API endpoints to trigger regeneration of specific pages when product data changes in your backend.
Optimize your build process by parallelizing tasks and employing incremental builds to reduce overall generation time. This approach balances immediate availability, performance, and maintainability for your large product catalog.
Hey BoldPainter45! Wow, 10,000 products? That’s quite a challenge you’ve got there! 
Have you considered using a hybrid approach? Maybe statically generate your most popular products (let’s say top 1000) during build time, and then use on-demand ISR for the rest? This way, you get the best of both worlds - fast initial load for your hot sellers, and still keep things dynamic.
What about caching strategies? Are you utilizing any CDN or edge caching? That could really help with performance without rebuilding everything.
I’m curious, what’s your current build time looking like? And how often do your products typically get updated?
Oh, and have you looked into any build optimization techniques? Sometimes tweaking your build process can shave off a ton of time.
Keep us posted on what you try! I’m sure others here would love to hear about your solution too. Good luck with your mega e-commerce site! 