For a while now (may have always been this way) we have been experiencing issues with load times on custom domains specifically. The weird thing about it all is, that the domain provided by netlify is consistenly fast on every pageload, while the site that is routed through cloudflare dns (with proxy off) is incredibly slow (~ 6 seconds TTFB) on the first load, then on every subsequent loads even from other devices and browsers the loads are perfectly normal. The site then continues loading quickly until no one accesses it for ~ 15 minutes, after which we again get the slow TTFB.
Sorry for the delay. This could have been due to some changes on our end, which have since been rolled back after multiple reports. Are you still seeing this?
I just tested again and it seems like sadly the problem is still occurring. I’m not 100% sure it has to do with netlify, but when hosting on other static site hosts through the same cloudflare setup we don’t see the same issues.
Sorry about that, seems like i might’ve submitted an incorrect file then, apparently i didn’t double check.
Here’s one where the initial HTML took 5.24 TTFB: https://we.tl/t-PaVmEWtNld
Thanks for the correct file. You seem to be using Next.js especially in the SSR more. This doesn’t use the CDN for the most part.
SSR responses would always take time because the requests go to AWS Lambda where they’re executed and a response is sent. Lambda Functions don’t run as a CDN, and rather are static to a single location. Furthermore, they suffer cold start issues, which would cause the functions to take some time to boot if they’re not accessed for some time - kind of what you’re seeing.
Thank you for the quick reply! Seems like that could indeed be our issue.
From what I’ve read, using SSG is more for sites where there’s a lot of static content. What we’re building is entirely dynamic and almost no pages are completely static. Do you think it still makes sense to switch? Are there any other solutions that would let us keep using SSR?
If you don’t need dynamic content on each page load, you are better off by using ISR. ISR would use Netlify On Demand Builders and would be cached like static assets for the time you’d specify in the revalidate. Once this time has elapsed, the next time the page is requested, it will continue to show a stale copy, but the page generation will trigger in the background. Once the new page is ready, that will be cached and served instead of the stale copy.
Hi @hrishikesh — so our site, myfuturestay.com is experiencing this same issue, but we indeed do need dynamic content via SSR. And the dynamic content is also determined by the subdomain of the site.
Is there anyway to prevent AWS lambda cold starts for NextJS sites on Netlify — or any solution to speeding up NextJS SSR on netlify?
I’m not seeing any significant slow loads for your site @bigwoof91. It’s loading in almost a second for me, which is kinda expected based on my current location.
Hi @bigwoof91 , sorry for the delay in response! We’ve looked into this. In your HAR file we see only your slow SSR function. This is not meant to be cached so it run every time. Your function does runs reliably somewhere between 500ms and 3.5s.