I have a react app which I deployed using Heroku to a custom domain with Cloudflare DNS about a week ago.
I've noticed a huge difference when loading the site using a custom domain vs the domain that Heroku provides us. More specifically, the TTFB waiting time is 26.17s. However, this only happens when I haven't opened the site for over 24h.
My suspicion tells me that the culprit is my Cloudflare DNS provider because I believe that the request goes through a proxy server which delays the request for some time.
Now, what I'm really trying to accomplish here is to reduce this TTFB time, but not sure what I should be looking into.
Any advice would be appreciated.
I have done an audit of the site, and I don't think there's a performance issue within the site:
My guess is you're using a free dyno, and if so Heroku puts the dyno to 'sleep' after 30 minutes without web traffic. When the sleeping dyno receives web traffic it will become active again, but after a short delay. This is probably the delay you're seeing.
In my experience, it can take at least several seconds for the dyno to become active again.