Next.js app filling up disk space in production

Viewed 218

I have a problem with the size of Next.js in production. The .next folder is filling up disk space really quickly, which kinda make sense, but want to know if I can optimize some configurations.

The website has many pages, and languages. 18 languages with about 20'000 pages each, so ~360'000 pages in total. A lot of them are generated with getStaticProps. They all have the same page structure page only the data changes (like an ecommerce with products basically).

Now the problem is that if I check the .next folder in production for each page I get a 300KB HTML file and a 250KB json file for the route <locale>/product/[id]/[...slug].

The file are incrementally generated so not all pages are created at build time, but only when users requests them.

With that many pages and file, I would need ~200GB disk space to store everything.

The question is: How can I avoid filling up the disk? Some pages are way less important/popular than others, so ideally I would like to have only "popular" pages saved, while all the other can be always generated when requesting the page.

I could write a script that runs periodically and delete the unwanted pages, but doesn't seems a good idea.

0 Answers
Related