Hello,
We are using your services to host our marketing website https://sensortower.com and I wanted to confirm if there are any limits on number of files/size of files that can be kept on the webserver.
We are using next.js to build and run our website and we expect it to dynamically render and save a lot (as in tens/hundreds of thousands) pages that will be stored on a filesystem. Each page should be really small (since it’s only html) but there will be a lot of them.
I found an information on our site-deploys/overview page that if DURING DEPLOY we have more than 54k files within our publish directory it will fail.
Does the limit apply only during deployment? Will it be fine if our website creates a lot of files during the runtime?
Kind regards,
Kacper
That 54k limit is per directory. You can still deploy more files as long as they’re in a different directory.
As for your question:
What exactly do you mean by runtime?
There’s no filesystem (persistent) on Netlify, so I’m not sure if what you’re trying will work.
Hi @hrishikesh,
Thanks for the quick response and sorry for the delay. I actually had to go and read some more documentation to understand our situation and be able to ask you correct questions.
So what I mean by that is that we use nextjs for our website and we are going to scale up number of our pages.
Since not all of them may be accessed by users and there will be a lot of them we thought about using ISR to render these pages once they are actually accessed and cache them for next requests (since they will very rarely change).
What I was wondering about is whether unlimited number of pages can be generated by nextjs and cached after build. That’s why I asked about filesystem limit, since AFAIK nextjs simply stores these files on filesystem.
Now from what I can see in your documentation it actually seems that nextjs ISR on netlify somehow uses your on-demand builders?. Edit: Ok, I found out that it’s all handled by nextjs-plugin.
According to your On-demand builders limits section it also seems that by default only 10k pages can be cached and anything above that limit is not guaranteed to be cached?
So as far as I understand (and please correct me if I’m wrong), these are our options:
- Generate all pages during build time and deploy them to serve as static assets. This would mean that we would have a very long build time and would need to have 54k files per directory max.
- Use nextjs getServerSideProps to render most pages dynamically. They will not be cached in any way and we’ll have to build them for every request. Additionally as per this page each render will use netlify functions anyway so it will be counted into our usage?
- Use nextjs getStaticProps to enable ISR. This will cause pages to be rendered dynamically and be stored using on-demand builders. This also means that we are limited to caching 10k pages (unless we contact sales and make a deal) and each page being rendered will count towards our functions usage?
So as far as I understand there is no way to use ISR in nextjs without using your on-demand builders? And also regardless whether we user ISR or Server Side Rendering it will still use functions?
Thanks for the help and explanation. Please let me know if I got something wrong here
I’m not sure about this. From what I know, Next.js stores this on a CDN cache and not filesystem, but I could be wrong.
Technically yes, practically, probably not. The pages you generate will be stored on the CDN cache. This same CDN is used by all the other sites. If your pages are not accessed frequently, your pages will be dropped from the CDN cache to make room for other files that are being accessed frequently. In a theorotical event where all of your websites pages are being accessed more than any other website on Netlify, sure your pages will remain cached.
That’s true for Next.js Runtime v4 and not the latest versions.
Not applicable anymore based on my above statement. But if you’re using the older versions, then yes that’s correct.
With Next.js Runtime v5, it doesn’t matter if you build all pages during build or using SSR/ISR. Everythig is routed by Functions.
Correct.
No On Demand Builders anymore. But any page that’s not returned from the CDN cache will invoke a Function.
Correct.
Thanks for the answer, I think it’s mostly clear to me now
So just to confirm two things to make sure that I understand it correctly:
- All static pages rendered during build time go to Netlify CDN and are served from there? When you say “Everythig is routed by Functions.” do you mean that even static pages may be rebuilt by Function when being accessed?
- All pages rendered using SSR or ISR are built using Function and MAY be cached in Netlify CDN IF they are accessed frequently. In practice most won’t be so some of them will be served from cache and most of them will be rendered again on next request.
Yes. Please refer to: After Upgrading from Next.js 14.0 to 14.2 NetlifyCacheHandler.get fails - #5 by hrishikesh
Yeah, that’s about right. We’re currently working on a central-caching primitive (so almost like a replacement for On Demand Builders but as a standard primitive instead of a proprietary feature) which could potentially change this in the future. But what you said is the currently true.
Thanks for all the help. I’m marking this as solved since I don’t have any further questions