Home > front end >  The time to first byte is very high
The time to first byte is very high

Time:06-14

The website takes long to respond back. The issue is not just from my laptop, but from 10s of other laptops as well. The chrome devtools reports 8seconds as TTFB. Rest of the images, javascripts are all downloaded within a second or two.

But when I run curl command, I can fetch the entire document in less than a second. The TTFB is reported as less than a second as well. Below is the command I used -

curl -o a.html -H 'Cache-Control: no-cache' -s -w "Connect: %{time_connect} TTFB: %{time_starttransfer} Total time: %{time_total} \n" https://gruhasutram.com

The website that I am trying to fix the issue is https://gruhasutram.com. I am running this one on godaddy with woocommerce plugin. Please note that, the webpage I am referencing here is a static website, without any involvement of the API or database call.

Appreciate if someone can help me answer the below questions

  1. Why does curl respond faster? Does it not indicate that, the server itself is able to respond faster?
  2. What can be the issue with the website? We have already optimized the images, javascripts (still opportunity exists). But why does it take 8 second for the first byte?

Thanks, Prasanna

CodePudding user response:

What I have noticed whilst taking a look at the network report for the website is that, two things are making it slow:

  1. Large images, >550kb, take a long time to download and retrieve. Maybe you can try to compress them or use another file type, I would recommend WebP for this use case.

  2. The server you are using for your assets (notably for fonts) has a very slow response time, the browser is spending more time waiting for a server response, way too long, than it is actually downloading the asset. To resolve this maybe try to migrate to another server/CDN than secureservercdn.net, like Cloudflare CDN. Or, you can just save the assets onto the same computer/server as you hosting your website on (but I am guessing that there is a reason you did not do that in the first place).

CodePudding user response:

It's not related to image size. Time to First Byte is the time taken for the HTML document to get from the server to the client.

Some of the other comments talk about image and font hosting. That will effect site speed, but not specifically TTFB (which is unaffected by these issues).

Some of the factors that contribute to the time are:

  1. The number of wordpress components
  2. The amount of resources available on the server
  3. The distance between the server and the client

I noticed in builtwith, that you have quite a few wordpress plugins: https://builtwith.com/detailed/gruhasutram.com

Removing any of these that are not needed might help. The suggestion to use a CDN is a good one, but you need one that will cache the HTML body in order to speed up TTFB. This will speed it up a lot but it requires a good configuration to ensure that you don't cache the URLs used for cart, checkout and other functions.

I've noticed your curl is quite fast, but when I'm using chrome, if I used a parameter (like ?123=123 at the end, changing each time) it takes 8-9 seconds. I can't reproduce this in curl. I'm guessing it is to do with how your server is dealing with sessions/cookies. Each time you run curl, it doesn't need to consider cookies. This might mean it is faster. In contrast, chrome with cookies/sessions is running slower.

  • Related