Time To First Byte

From Wikipedia, the free encyclopedia
Jump to: navigation, search

Time To First Byte (TTFB) is a measurement used as an indication of the responsiveness of a webserver or other network resource.

TTFB measures the duration from the virtual user making an HTTP request to the first byte of the page being received by the browser. This time is made up of the socket connection time, the time taken to send the HTTP request, and the time taken to get the first byte of the page.

Often this can be seen as a benchmark of a good server side program. The lower the Time To First Byte, the fewer calculations the dynamic webserver is doing. Often times are low for statically served web pages, and can be as slow as tens of seconds for large data requests from a database.

Uses in web development[edit]

Time To First Byte is important to a webpage since it indicates pages that load slowly due to server-side calculations that might be better served as client side scripting. Often this includes simple scripts and calculations like transitioning images that aren't gifs and are transitioned using Javascript to modify their transparency levels. This can often speed up a website by downloading multiple smaller images through sockets instead of one large image. However this technique is more intensive on the client's computer and on older PCs can slow the webpage down when actually rendering.

Time To First Byte is so important that some webpages have forgone eager loading for lazy loading in an attempt to make their content appear to load faster. This is helpful with webpages that have many images and large amounts of data. However there are several reasons that TTFB can be high:

  1. database requests are fast but often require post-query logic to format the data for the end user;
  2. Application Programming Interfaces used on the server-side can increase overall response time, as is common in Restful APIs that process large amounts of data from a database.