Websites that have tested pagespeed insights will encounter the prompt "Reduce initial server response time".The initial server response time can affect the page loading time and performance indicators, such as maximum content rendering, core web life indicators, and PageSpeed scores.that isTTFBThe smaller the better.
When troubleshooting websites that open slowly,First byte time(TTFB) is an important indicator.If you are looking for effective ways to reduce the TTFB time of WordPress websites and servers, this article can provide you with some valuable directions and ideas.
What is TTFB (first byte time)?
Full name of TTFB: Time to First Byte.What are you waiting for?In addition to the time it takes to wait for the server to deliver the response, there is also a delay in the round trip to the server.
It refers to the time from the time when the visitor sends an HTTP request (such as opening a domain name) to the time when the user's browser receives the first byte.The process is basically like this: the visitor sends an access request and locates the CDN node or host server from the domain name resolution.Read the website data and return it to the user's browser until the page content is loaded.
In short, TTFB is the time from the moment you open a web page to the moment when the page is presented. As the name implies, it is a period of "waiting".
The following is the action of the server: a content management system (CMS) such as WordPress. The server needs to execute all static (text, pictures, videos) and dynamic content (php files, databases) of the page. PHP computing and reading databases are time-consuming.The PHP service loads the MySQL database of the website, obtains the content, calculates the HTML output, and returns it to the website visitor.
TTFB includes three sections:
1. Time when the HTTP request was sent
TTFB starts when a visitor sends an HTTP request. The time the server receives the request mainly depends on the DNS lookup time, the user's network speed, the geographical distance between the server and the server, and possible interruptions in the connection.
2. Time to process the request
When the server receives the request, it will process the request and respond.It includes starting the php process, entering the database to search and call, running the js script, css style sheet, and communicating with other network systems.
3. Time required for the server to send the first byte of the response back to the browser
The server sends the response to the user.It depends on the network speed of the server and the user.
The above steps all take time. If the optimization is not good, the TTFB of the website will be very high, such as more than 10 seconds or more.
The longer it takes to send a request to the server, process the request, and send the processed data back to the user's browser, the longer it takes to display the web page. We call it TTFB is too large and needs optimization.
But it is not necessarily because the host is slow. It is also possible that too many plug-ins have been installed (I have seen 50+plug-ins installed, and more to say). The cache system is not used, and the PHP 5.6 version with low performance has been used (except for special cases).
We can't manage the users. We can only find ways to optimize the server and CDN (manage ourselves).
How normal is TTFB?
Google recommends that the TTFB be less than 200 ms.Lighthouse thinks that the request is unqualified after 600 milliseconds.
If the TTFB is longer than 1 second or even larger, it means that there are some performance bottlenecks in the server, and the problem needs to be found and optimized.
As shown in the figure,Weiss NotesTTFB of about 500 ms.
Measure TTFB value
Generally, you can use the Gtmetrix website to test the TTFB value of your website and use it as a reference.
Many foreign websites can test the TTFB value, and it is OK to know that there is such a thing.
Select [Hong Kong, China] node test for domestic websites;Select [Canada] or [United States] node test for foreign websites.
Causes of high TTFB
WordPress website has several factors that affect the time of the first byte: DNS response time, network latency, server configuration and performance, and dynamic content.
We use the following 9 methods to reduce TTFB (first byte time) in WordPress.
Use a fast network host
Using a stable and fast host server will greatly reduce TTFB.
For example, most of the visits to Weiaisi's notes are in China, so we chooseTencent ECSAs the basic platform of the website.
Selecting a host node with more visitors, whose physical location is closer to the user's location, will effectively reduce TTFB.
In addition, there are also options in ChinaAliCloud server, also have excellent quality.
While most users of foreign trade websites and cross-border e-commerce websites are located in the United States, it is recommended to host the websites in the United States.If most users are in Europe, they should be hosted on European nodes.If there are both American and European customers, they should be placed at the American node.
Suggested choice of foreign trade B2B website and cross-border e-commerce websiteSiteground、HostingerVirtual host and other platforms.2C suggested choice of websiteVultrHost station establishment.
The host server is very important, which is the cornerstone of building a website.If the cornerstone is unstable and has poor performance, you will get twice the result no matter how you optimize it.
Use CDN
CDN can help websites send static content of websites to users faster through cache server nodes all over the world.
For example, if your host is placed on the American host, when European users visit, they will call the website content from the cache server of the nearby Amsterdam CDN node in the Netherlands, without visiting your American host, which saves the round trip time from Europe to the United States.It effectively reduces the network latency between the website host and visitors.
Ordinary DNS does not provide advanced DNS functions, that is to say, DNS services provided by domain name providers are free, while paid DNS packages can provide more DNS resolver nodes, making DNS resolution faster.Good DNS providers will use DNS server networks all over the world to answer DNS queries with low latency and reduce TTFB.
Wei Aisi's notes have been purchasedTencent Cloud DNS Resolution Package, which is faster than the normal free DNS resolution to answer access requests.
After GZIP compression is enabled, the size of HTML, CSS and JS files will be greatly reduced, the page resources will be downloaded faster, and the TTFB will be reduced.
Common database garbage, such as article revisions, deleted and garbage comments, and temporary files created by plug-ins, will affect the server response time.
It is strongly recommended to optimize the database size and clean up garbage regularly.
WordPress program, plug-in and theme updates will affect the query of code running to the database or affect the running efficiency of PHP code.
Please check the plug-ins and themes regularly. It is recommended to keep only the plug-ins and themes used and delete the ones not used.
Choosing the right theme and plug-in is also a very skillful thing.The code quality of plug-ins and themes will affect TTFB. Some plug-ins will run in the background, and the website will be checked at intervals.Some topic codes query the database too many times, and TTFB will be added.
In general, it is necessary to update WordPress, plug-ins and themes regularly.
Reduce database queries
WordPress reads the database several times, and too many queries will affect TTFB.
Article name: What is TTFB (first byte time)? How to reduce TTFB Article link:https://www.vpsss.net/28514.html Copyright notice: The resources of this website are only for personal learning and exchange, and are not allowed to be reproduced and used for commercial purposes, otherwise, legal issues will be borne by yourself. The copyright of the pictures belongs to their respective creators, and the picture watermark is for the purpose of preventing unscrupulous people from stealing the fruits of labor.