I have a website hosted on EC2 with most css, JS and images loaded from Cloudfront. There is a consistent problem that even small css and js files have 1-2 seconds time to first byte, even where there is a cache hit on Cloudfront. Here is a screenshot from websitepulse:
None of these css files are particularly large. I have also run this test twice straight after each other, but there seems to be no difference.
Is there any limit I may be hitting on Cloudfront? Or any sort of interdependence of requests because of HTTP2?
I was having TTFB as 1.5s. After few hours of digging, I realised that the reason was in my ...
DNS
.I was using some family safe DNS which was causing the lag. Switching back to Google's
8.8.8.8
did the trick.