Jump to content

Time to first byte

From Wikipedia, the free encyclopedia
(Redirected from Time To First Byte)

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 user or client making an HTTP request to the first byte of the page being received by the client's browser. This time is made up of the socket connection time, the time taken to send and the time taken to get the first byte of the page.[1] Although sometimes misunderstood as a post-DNS calculation, the original calculation of TTFB in networking always includes network latency in measuring the time it takes for a resource to begin loading.[2] Often, a smaller (faster) TTFB size is seen as a benchmark of a well-configured server application. For example, a lower time to first byte could point to fewer dynamic calculations being performed by the webserver, although this is often due to caching at either the DNS, server, or application level.[1] More commonly, a very low TTFB is observed with statically served web pages, while larger TTFB is often seen with larger, dynamic data requests being pulled from a database.[3]

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 are not 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.

Importance

[edit]

TTFB is often used by web search engines like Google and Yahoo to improve search rankings since a website will respond to the request faster and be usable before other websites would be able to.[4] There are downsides to this metric since a web-server can send only the first part of the header before the content is even ready to send to reduce their TTFB. While this may seem deceptive it can be used to inform the user that the webserver is in fact active and will respond with content shortly. There are several reasons why this deception is useful, including that it causes a persistent connection to be created, which results in fewer retry attempts from a browser or user since it has already received a connection and is now preparing for the content download.[5]

TTFB vs load time

[edit]

Load time is how long it takes for a webpage to be loaded and usable by a browser. Often in web page delivery a page is compressed in the Gzip format to make the size of the download smaller.[5] This practice prevents the first byte from being sent until the compression is complete and increases the TTFB significantly. TTFB can go from 100–200 ms to 1000–20000 ms, but the page will load much faster and be ready for the user in a much smaller amount of time. Many websites see a common 5–10× increase in TTFB but a much faster browser response time garnering 20% load-time decrease.

References

[edit]
  1. ^ a b Wagner, Jeremy (22 December 2016). Web Performance in Action: Building Fast Web Pages. Simon and Schuster. ISBN 978-1-63835-376-8.
  2. ^ Tu, Kenneth; Hasan, Jeffrey (1 January 2008). Performance Tuning and Optimizing ASP.NET Applications. Apress. ISBN 978-1-4302-0758-0.
  3. ^ Artasanchez, Alberto (19 February 2021). AWS for Solutions Architects: Design your cloud infrastructure by implementing DevOps, containers, and Amazon Web Services. Packt Publishing Ltd. ISBN 978-1-78953-914-1.
  4. ^ Silhavy, Radek (22 August 2022). Software Engineering Perspectives in Systems: Proceedings of 11th Computer Science On-line Conference 2022, Vol. 1. Springer Nature. ISBN 978-3-031-09070-7.
  5. ^ a b Panigrahi, Bijaya Ketan; Trivedi, Munesh C.; Mishra, Krishn K.; Tiwari, Shailesh; Singh, Pradeep Kumar (11 July 2018). Smart Innovations in Communication and Computational Sciences: Proceedings of ICSICCS 2017, Volume 2. Springer. ISBN 978-981-10-8971-8.