What Causes TTFB?
High Time to First Byte, or TTFB, is a commonly misunderstood problem on websites. It’s easy to look at this metric strictly as a server issue. The reality is, high TTFB doesn’t necessarily mean your server is slow or overloaded. So why would a page show over 1 second for TTFB if the server’s load looks just fine? The answer typically comes down to the dynamic page creation process required with PHP sites.
PHP vs HTML
To fully understand this issue, you’ll first want to take a look at PHP’s predecessor: HTML. HTML websites offer a nice simplicity in that when a page is requested, the web server simply has to locate and serve a static file. With WordPress and other PHP-based sites, the web server follows a set of directives to generate the page by executing PHP code and communicating with a database.
The database provides information like what page content exists on each page, post ID, URL, and autoloaded options. Once the page has been generated, it can be served to your site’s visitor. So while HTML has a single file to serve on a page visit, PHP has to create everything as new each time the page is requested. By nature, this takes longer! That’s expected. But PHP offers far more diversity in the level of dynamic content it can serve, which is why so many users still choose this option.
Cause and Effect
So what should you try if you have a high TTFB? What if it’s intermittent? How does it affect your site? For one, high TTFB could cause a high bounce rate if it gets high enough. Users typically will wait 2-3 seconds to start seeing content on your site before they leave, or at least have a degree of frustration. Not to mention, TTFB could affect your search rankings too. Google ranks pages based on popularity, but also on how fast they load, security, and mobile readiness.
Troubleshooting
If your WordPress site is plagued by high TTFB, start troubleshooting by creating an uncached dev environment to factor out any page caching that’s been helping intermittently. Since page cache stores a static copy of your page to be served to repeat visitors, it can often confuse the matter by showing low TTFB intermittently on your tests. Using an uncached environment will give you a clearer view of what’s truly causing the issue.
In your staging environment, start by eliminating factors en masse – try deactivating all plugins, or activating a default theme. After each, test your TTFB using a resource like www.webpagetest.org. If it ends up being the plugins, start enabling them one at a time (or in smaller groups if you have a lot of plugins to get through). After each change, note how fast your site loads and run a test. Once you have narrowed it down, you can also try a diagnostics tool like the Query Monitor plugin to show you if any queries to the database are to blame. This might help you determine if there’s a specific setting in your plugin or theme affecting your TTFB.
What struggles with TTFB have you experienced? Were you able to find the source of your issue? Tell your story in the comments.
Leave a Reply