DEV Community

Danish Ali
Danish Ali

Posted on

Starting the performance journey. TTFB

We start the journey by typing www.ourwebsite.com, this will send a get request to our server to retrieve the page's HTML. So our first task is to make this retrieval fast.

This step is indicated by a metric - TTFB, Time to First Byte

TTFB is not the most important, but as its the first that means it will affect every other coming metric.

TTFB matters more in client side rendered applications than in server side rendered, as Client sides totally depends on js files populating it.

All sites should strive for TTFB of 0.8 seconds or less, you can measure the TTFB with lighthouse or other profiling tools, it will be shown as "Initial server response time".

Here are some way to optimise TTFB

  • Hosting - Make sure you have good hosting provider, allocate sufficient memory space, configure server settings.

  • Use CDN for serving static files, JS,HTML,CSS and images.

  • Send resources in chunks

  • Send 103 Early Hints for render-critical resources: "The 103 Early hints header is an early response code that the server can send to the browser while the backend is busy preparing markup. This header can be used to hint to the browser that there are render-critical resources the page should begin downloading while the markup is being prepared." Google, web.dev

Top comments (0)