Time to first byte - Wikipedia https://en.wikipedia.org/wiki/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 the HTTP request, and the time taken to get the first byte of the page. 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.[1]

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

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.

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.[2] 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.

The steps for optimizing TTFB are as follows:

  1. Check your server. For example: If there are complex firewall rules or routing issues then the TTFB time may be huge.
  2. Check your application.

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. 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–2000 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. There are some drawbacks however in using Gzip compression:

  1. server CPU load increases during compression.
  2. data can take a long time to process and since a first byte isn't sent until it's done compressing it can make the webpage appear to be hung.
  3. long times to first bytes will often cause a user to cancel and reissue their request to the web-server resulting in increased CPU loads because of sequential load requests.

References[edit]

  1. Jump up^ "TTFB Is Still (And Always Will Be) Meaningless"LittleBizzy. 15 November 2015. Retrieved 2015-11-16.
  2. Jump up^ "Improving Search Rank by Optimizing Your Time to First Byte"Moz. Retrieved 2016-06-21.

Stop worrying about Time To First Byte (TTFB) https://blog.cloudflare.com/ttfb-time-to-first-byte-considered-meaningles/

Time To First Byte (TTFB) 第一字节时间 页面加载时间的更多相关文章

  1. 我是如何将页面加载时间从6S降到2S的?

    写在前面 生活在信息爆炸的今天,我们每天不得不面对和过滤海量的信息--无疑是焦躁和浮动的,这就意味着用户对你站点投入的时间可能是及其吝啬的(当然有一些刚需站点除外). 如何给用户提供迅速的响应就显得十 ...

  2. 利用Navigation Timing测量页面加载时间

    最近在看一本名为<web性能实践日志>的书籍,其中第十三章"网络计时"中介绍了一种比较新的计算页面各部分加载时间方法,这也是W3C Web性能工作小组正在做的事情,接下 ...

  3. selenium学习笔记11——driver.get(url) 页面加载时间太长

    在执行自动化测试用例过程中,发现因为网络慢或其他原因导致driver.get(url) 时,页面一直在加载,页面没有加载完成就不会去继续执行下面的动作,但是实际上需要操作的元素已经加载出来了. 解决方 ...

  4. selenium学习笔记——driver.get(url) 页面加载时间太长

    # 两个同时设置才行 # 实现效果:加载状态停止,进行代码下一步操作 driver.set_page_load_timeout(10) driver.set_script_timeout(10) # ...

  5. [转载]Python & Selenium -- 页面加载时间过长&启动指定FF

    原文链接:https://my.oschina.net/u/2344787/blog/400507?p={{page}} 1. selenium webdriver在get方法会一直等待页面加载完毕才 ...

  6. Selenium WebDriver- 指定页面加载时间

    #encoding=utf-8 import unittest import time from selenium import webdriver from selenium.webdriver i ...

  7. 使用Filter跟踪Asp.net MVC页面加载时间

    最近,客户一直反馈系统使用慢,有时候能够指出具体是哪个页面,有时候又只是笼统地反馈慢.这种问题就像是幽灵一样,非常不好处理.因为导致这种问题的因素非常之多,而且在开发工程中,很难模拟出实际运行是的环境 ...

  8. web开发的性能准则(减少页面加载时间方面)

    准则(概述) 减少 HTTP 请求 使用CDN加速 避免空的src或href属性值 增加过期头 启GZIP压缩 把css文件放到头部 把javascript放到尾部 避免使用css表达式 删除不使用的 ...

  9. 将jquery和公共样式缓存到localStorage,可以减少Http请求,从而优化页面加载时间

    以下代码: //入口函数 if (window.localStorage) { initJs(); initCss("css", "/gfdzp201508257998/ ...

随机推荐

  1. AC日记——传纸条 洛谷 P1006

    题目描述 小渊和小轩是好朋友也是同班同学,他们在一起总有谈不完的话题.一次素质拓展活动中,班上同学安排做成一个m行n列的矩阵,而小渊和小轩被安排在矩阵对角线的两端,因此,他们就无法直接交谈了.幸运的是 ...

  2. (3)unity3d 地形

    在Hierarchy(层次) 建一个Terrain(地形) Terrain属性按钮 第一个按钮:抬升与下陷地面.单击抬升地形,同时按住shift下陷地形 第二个按钮:绘制高度.同时按住shift绘制等 ...

  3. POJ 3107 Godfather (树重心)

    题目链接:http://poj.org/problem?id=3107 题意: 数重心,并按从小到大输出. 思路: dfs #include <iostream> #include < ...

  4. javascript --- 对象之间的继承

    了解这一章之前,先把我们之前讲到的以构造函数创建对象为前提的继承抛到一边. 首先,我们先用一个var o = {}创建一个没有任何属性的空对象作为我们的‘画板’,然互在逐步向这个画板里添加属性,和方法 ...

  5. Objective-C 的 API 设计(转)

    英文原文:API Design 转自oschina 参与翻译(14人): 李远超, 魏涛, showme, weizhe72, 周荣冰, crAzyli0n, WangWenjing, throwab ...

  6. 在谈MVP之前,你真的懂MVC吗?

    最近看到很多文章在谈论MVP或者MVVM模式的,但其实无论MVP还是MVVM都只是MVC模式的一种变种.而如果你对MVC的设计理念都还没有理解透彻,那么即使换成MVP亦或MVVM也不可能让你杂乱不堪的 ...

  7. 【转载】React入门实例教程-读书笔记

    参考了这篇文章: http://www.ruanyifeng.com/blog/2015/03/react.html 其中github 安装配置见上一篇文章(link) 一.HTML 模板 使用 Re ...

  8. Git学习0基础篇(下)

    server上的 Git - 协议 Git能够使用四种基本的协议传输资料:本地协议(Local).HTTP 协议.SSH(Secure Shell) 协议以及 Git 协议.眼下使用最普及的是 SSH ...

  9. HDU2256-Problem of Precision(矩阵构造+高速幂)

    pid=2256">题目链接 题意:求sqrt(sqrt(2) + sqrt(3)) ^ 2n MOD 1024 思路: 代码: #include <iostream> # ...

  10. cug oj 1479 Treasure Chest Lock (区间dp 思维)

    1479: Treasure Chest Lock Time Limit: 1 Sec  Memory Limit: 128 MB Submit: 7  Solved: 5 [id=1479" ...