Very slow TTFB on first page load in a while

Hello Netlify Community!

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.

The netlify site domain is: https://modest-turing-407bcb.netlify.app/
The domain routed through cloudflare: https://etournity.app/

Here’s a HAR of one of the slow loads: https://we.tl/t-uhbhYedSta

Any pointers or suggestions are very welcome, we’ve been struggling to find out what makes this happen for quite a while now.

Hey @Julian_Karhof,

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?

Hey there, thanks for the reply!

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.

Upon checking the HAR file you’ve submitted above, I don’t see any files with high TTFB.

The highest one is this:

Which is still considered normal from our end.

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

And here’s a screenshot:

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.

1 Like

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.