How To

WordPress TTFB Optimization: 12 Tweaks to Reduce Time to First Byte

A good WordPress TTFB is 0.8 s or less per web.dev. Twelve tweaks in order, with a curl check for each, plus the mistakes people report.

Varun DubeyVarun Dubey
·16 min read
Bar chart of the phases before the first byte: DNS, connect, TLS and server time, with a 0.8 second marker

A good TTFB for a WordPress page is 0.8 seconds or less, and anything above 1.8 seconds is poor, according to web.dev. Our working targets are stricter: a cached page should answer in a fraction of a second from the edge, and an uncached page should stay under the 600 ms that Lighthouse uses as its pass line. This post gives 12 tweaks in the order we would apply them, plus a way to measure each one so you are not guessing. We checked every tool, setting and number below on 15 November 2026.

What is a good TTFB, and is it a Core Web Vital?

TTFB is not a Core Web Vital. web.dev says so directly: it is a diagnostic that sits in front of the vitals, and a site that passes its other metrics does not strictly have to hit the TTFB threshold. The article calls 0.8 seconds or less “good” and more than 1.8 seconds “poor”, and describes 0.8 seconds as a rough guide, not a rule.

It still matters because everything else waits on it. The browser cannot paint, parse a stylesheet or discover the hero image until the first byte of HTML shows up, so a slow TTFB pushes First Contentful Paint and Largest Contentful Paint back by the same amount.

Lighthouse draws a separate line. Its server response time audit fails when the main document takes more than 600 ms to arrive after the request is sent, and it counts only server time, not DNS or redirects. If you see a PageSpeed Insights warning about initial server response time, that is the audit you are looking at.

What TTFB includes is the part people forget. By the same web.dev definition it covers redirect time, service worker startup, the DNS lookup, the connection and TLS handshake, and the request itself up to the first byte of the response. A slow WordPress install is only one of the possible causes.

How do I measure TTFB without fooling myself?

Measure three different requests, because they fail for different reasons. A cached anonymous page tells you whether your page cache and CDN work. An uncached anonymous page tells you how heavy WordPress itself is. A logged-in request tells you what members, customers and editors feel, and that is the one most speed tests never see.

PageSpeed Insights and WebPageTest request pages without cookies, so they only ever test the first case. That is the main reason a site can score well in a lab test while logged-in users complain.

Break the request into phases with curl

curl can split one request into its phases, which separates network time from server time in a single command. Run it from where your visitors are.

curl -o /dev/null -s -H 'Accept: text/html' \
  -w 'dns %{time_namelookup}\nconnect %{time_connect}\ntls %{time_appconnect}\nttfb %{time_starttransfer}\ntotal %{time_total}\n' \
  https://example.com/

Checked on 15 November 2026. The values are cumulative seconds from the start of the request. Subtract tls from ttfb to get the time the server spent producing the first byte, which is what the WordPress tweaks below change. Run it five times and read the median.

Check whether the cache answered

curl -sI -H 'Accept: text/html' https://example.com/ | grep -iE 'cache|age|server-timing'

Look for the header your stack uses: cf-cache-status on Cloudflare, x-cache or x-fastcgi-cache on many Nginx setups, x-litespeed-cache on LiteSpeed. A HIT means PHP never ran. A MISS or DYNAMIC means it did, and the rest of this post applies to that request. To force an uncached page for testing, add a throwaway query string such as ?x=123. Many page caches and Cloudflare APO treat unknown query strings as a bypass, but confirm it with the headers instead of assuming.

Put WordPress’s own time in a header

The Server-Timing header shows up in the browser’s Network panel under Timing, so a single small snippet gives you PHP time on every uncached request. This one measures from the start of the request to the moment WordPress has finished loading plugins, running the main query and is ready to pick a template.

add_action( 'template_redirect', function () {
	$ms = ( microtime( true ) - $_SERVER['REQUEST_TIME_FLOAT'] ) * 1000;
	header( sprintf( 'Server-Timing: wp;dur=%.1f;desc="WordPress until template_redirect"', $ms ) );
}, 0 );

Checked on 15 November 2026 (syntax verified with php -l on PHP 8.5). Put it in a must-use plugin while you test and remove it afterwards. A cached response carries the header from whenever it was generated, so only read it on a MISS.

Is my slow TTFB the server or the network?

Compare three TTFB readings from the same location: a static file such as a theme stylesheet, a cached HTML page and an uncached HTML page. The static file has no PHP in it, so its TTFB is your floor: DNS, connection, TLS and the distance to the server. If the floor is already high, no WordPress tweak will fix it, and the answer is a CDN, a closer server region or fewer redirects.

  • Static file slow, everything slow: network or web server. Look at distance, TLS, redirects and the host.
  • Static file fast, cached page fast, uncached page slow: WordPress is the problem. Work through tweaks 3 to 9.
  • Static file fast, cached page slow: your cache is not serving that page. Work through tweaks 1 and 2.
  • Everything fast anonymously, slow logged in: the cache is bypassed for you, which is normal, so the uncached path has to be fast. Same fix list as the second case.

The 12 tweaks, in the order we would apply them

Each tweak says what it changes, how to check it worked and where it stops helping. We left out percentage claims on purpose. The gain depends on your hosting, your plugins and how much of your traffic is cacheable, so measure your own site with the commands above before and after.

Tweak 1: Turn on page caching and prove it hits

A page cache stores the finished HTML so PHP and MySQL never run for repeat anonymous requests. It is the largest single change for most sites, because a cached response is a file or a memory read.

Your choice depends on your server. We checked the main free options on 15 November 2026 against the WordPress.org plugin directory:

  • LiteSpeed Cache: 7 million+ active installs, version 7.9.3, updated 3 November 2026. Its server-level page cache needs LiteSpeed, OpenLiteSpeed, LiteSpeed-powered hosting or QUIC.cloud. On other servers only the general features work.
  • WP Super Cache: 1 million+ active installs, version 3.1.5, updated 2 November 2026. It writes static HTML files and can serve them through PHP or through Apache rewrite rules.
  • W3 Total Cache: 900,000+ active installs, version 2.11.0, updated 20 October 2026.
  • WP Rocket is a paid plugin that is not in the WordPress.org directory, so it has no public install count to quote.

Many hosts also run a server-level cache that makes a plugin unnecessary, and running two page caches at once creates stale-page bugs that are hard to trace. Ask your host what is already active before you install anything. To confirm it works, run the header check from the measuring section twice on the same URL: the second request should show a hit and a much lower TTFB.

Tweak 2: Find out why requests bypass the cache

A cache that exists is not a cache that hits. Logged-in users bypass it by design, and so does any request with a cookie the cache does not recognise, a query string it has not been told to ignore, or a POST. A marketing cookie set on every visit can quietly turn most anonymous traffic into misses.

We wrote a full walkthrough of that problem in the cookies quietly bypassing your WordPress page cache. The short version is to read your real cache hit ratio from server logs, list the cookies on missed requests, and write bypass rules that match the specific cookie names instead of a broad prefix.

Here is the shape of a narrow rule set for Nginx FastCGI caching. The directives fastcgi_cache_bypass and fastcgi_no_cache are documented in the Nginx FastCGI module reference. Adapt the paths and zone name to your server and run nginx -t before you reload.

# http context
fastcgi_cache_path /var/cache/nginx/wp levels=1:2 keys_zone=WPCACHE:100m inactive=60m;

map $http_cookie $skip_cookie {
    default 0;
    ~*wordpress_logged_in_    1;
    ~*comment_author_         1;
    ~*wp-postpass_            1;
    ~*woocommerce_items_in_cart 1;
}

# server context
set $skip_cache $skip_cookie;
if ($request_method = POST)      { set $skip_cache 1; }
if ($query_string != "")         { set $skip_cache 1; }
if ($request_uri ~* "/wp-admin/|/wp-json/|/xmlrpc\.php|wp-login\.php") { set $skip_cache 1; }

# inside the location that passes .php to PHP-FPM
fastcgi_cache        WPCACHE;
fastcgi_cache_key    "$scheme$request_method$host$request_uri";
fastcgi_cache_valid  200 301 302 10m;
fastcgi_cache_bypass $skip_cache;
fastcgi_no_cache     $skip_cache;
add_header           X-FastCGI-Cache $upstream_cache_status;

Checked on 15 November 2026 against the Nginx documentation; we did not run it on a live server for this post, so test on staging first.

Tweak 3: Add a persistent object cache

WordPress keeps an object cache in memory for the length of one request. A persistent object cache keeps it between requests, so options, user objects, term lookups and many query results come from memory instead of MySQL. The WordPress performance optimization handbook describes it as a way to cut database trips and speed up response times such as TTFB. It needs a cache server from your host and a compatible plugin.

The WordPress hosting handbook lists APCu, Memcached and Redis as alternatives for the cache backend, so you only need one of them. If you pick Redis, the Redis Object Cache plugin (500,000+ active installs, version 3.0.0, updated 18 September 2026) supports PhpRedis, Predis and Relay and ships WP-CLI commands.

wp plugin install redis-cache --activate
wp config set WP_REDIS_HOST 127.0.0.1
wp config set WP_REDIS_PORT 6379
wp redis enable
wp redis status

Checked on 15 November 2026 against the plugin’s install notes. The status command should report the drop-in as valid and Redis as connected. An object cache helps the uncached path and logged-in users the most. It does little for a page that a full-page cache already serves, and it can do harm if code writes straight to the database without clearing cached copies, which we cover in the mistakes section.

Tweak 4: Run a supported PHP version

Newer PHP releases are faster for the same code, but the stronger reason to upgrade is that old branches stop getting fixes. The PHP supported versions page shows, as of 15 November 2026, PHP 8.4 and 8.5 in active support, PHP 8.3 and 8.2 in security-only support, and 8.1 already end of life. PHP 8.2 loses security support on 31 December 2026.

The WordPress requirements page asks hosts for PHP 8.3 or greater, and the hosting handbook goes further, recommending PHP 8.4 or later for production environments. Switch on staging first, read the debug log, and then move production. A plugin that is not ready for a newer PHP shows up as deprecation notices long before it becomes a fatal error.

While you are in the hosting panel, check the database too. The requirements page asks for MariaDB 10.11 or greater, or MySQL 8.4 or greater, and the handbook marks MySQL 8.0 as end of life since 30 April 2026.

Tweak 5: Check that OPcache is on, sized and not full

OPcache keeps compiled PHP in shared memory, so WordPress core and your plugins are not parsed again on every request. It is usually on by default, so the useful check is whether it is big enough. The PHP manual lists these defaults: opcache.memory_consumption 128 MB, opcache.interned_strings_buffer 8 MB, opcache.max_accelerated_files 10000, opcache.validate_timestamps on and opcache.revalidate_freq 2 seconds.

A site with many plugins can pass 10,000 PHP files, and a full cache silently drops the files that do not fit. Check the live numbers from a web request. Running the same check through WP-CLI is misleading, because OPcache is normally off for the command line (opcache.enable_cli defaults to 0).

<?php
// opcache-check.php: upload, open once in a browser, then delete it.
$s = opcache_get_status( false );
echo '<pre>';
echo 'enabled: ' . var_export( $s['opcache_enabled'], true ) . "\n";
echo 'cached scripts: ' . $s['opcache_statistics']['num_cached_scripts'] . ' of max ' . $s['opcache_statistics']['max_cached_keys'] . "\n";
echo 'hit rate: ' . round( $s['opcache_statistics']['opcache_hit_rate'], 2 ) . "%\n";
echo 'memory used: ' . round( $s['memory_usage']['used_memory'] / 1048576 ) . ' MB, free: ' . round( $s['memory_usage']['free_memory'] / 1048576 ) . " MB\n";
echo 'out-of-memory restarts: ' . $s['opcache_statistics']['oom_restarts'] . "\n";
echo '</pre>';

Checked on 15 November 2026 (syntax verified with php -l on PHP 8.5). If cached scripts sit close to the maximum, or free memory is near zero, raise opcache.max_accelerated_files or opcache.memory_consumption. The same manual page says opcache.revalidate_freq is ignored when opcache.validate_timestamps is off. With timestamp checks off you must reset OPcache on every deploy, which is the usual cause of stale code after an update. Our OPcache settings guide goes through each directive.

Tweak 6: Trim autoloaded options

On every request WordPress loads all autoloaded options from wp_options in one query. A few hundred kilobytes there is fine. Megabytes of leftover plugin data is not, because it is read, unserialized and held in memory before any page logic runs. The WordPress optimization handbook suggests keeping autoloaded data under 800 KB, and WordPress core’s Site Health check flags a site when the total passes 800,000 bytes (the filter is site_status_autoloaded_options_size_limit).

# total autoloaded size in bytes
wp option list --autoload=on --format=total_bytes

# stop autoloading one option (WP-CLI 2.8.0 or later)
wp option set-autoload some_big_option off
SELECT option_name, LENGTH(option_value) AS bytes
FROM wp_options
WHERE autoload IN ('yes', 'on', 'auto-on', 'auto')
ORDER BY bytes DESC
LIMIT 20;

Checked on 15 November 2026. The list of autoload values matters: since WordPress 6.6 the column can hold on, off, auto, auto-on and auto-off as well as yes and no, and core’s own wp_autoload_values_to_autoload() returns yes, on, auto-on and auto as the values that load. A query that only matches ‘yes’ undercounts. WordPress 6.6 also stops autoloading new options that do not state a preference and exceed 150,000 bytes (the wp_max_autoloaded_option_size filter), but options added before that stay as they were.

Read the top rows before you change anything. Turning off autoload for an option the theme needs on every page just moves the cost into an extra query, so only change options you can name and whose plugin you understand, and take a database backup first.

Tweak 7: Find slow queries with Query Monitor

Query Monitor (200,000+ active installs, version 4.1.1, updated 27 October 2026) flags slow, duplicate and erroneous queries and lets you filter them by the plugin, theme or core component responsible. By default it marks a query as slow after 0.05 seconds, which comes from the QM_DB_EXPENSIVE constant in its source, and you can change that in wp-config.php.

There is one catch. By default only administrators see its output, which means you are measuring a logged-in request. That is the right test for the uncached path, but it also loads admin-only code. Use its setting for viewing output while logged out through an authentication cookie when you want to profile a front-end page as a visitor. Our Query Monitor tutorial covers every panel.

Work down the Queries panel in this order: the slowest single queries, the duplicates, and then the components that account for the most total time. On the database side, turn on the MySQL slow query log with slow_query_log=1 and a long_query_time you choose, and use EXPLAIN on the offenders. Missing indexes on custom tables are the usual finding. Our MySQL tuning guide covers the InnoDB settings.

Tweak 8: Cut the plugin and theme bootstrap cost

Every active plugin is loaded on every uncached request, and its init hooks run whether or not the page uses it. Query Monitor’s Hooks and Actions panel and its component breakdown show where time goes. Look for plugins that run queries on every front-end request, check licences on page load, or register heavy hooks on pages that do not need them. Confirm on staging: measure uncached TTFB, switch off one suspect, measure again.

Tweak 9: Stop blocking on external HTTP calls

An HTTP request made during page generation holds PHP until the other server answers. WordPress’s default timeout for those requests is 5 seconds (the http_request_timeout filter in core), so a slow licence server or social API can add seconds to TTFB for every uncached visit. Query Monitor’s HTTP API Calls panel shows each request with its response code, the component responsible and the time taken, which makes the offender easy to spot.

The fix is to move the call out of the page request. Cache the result in a transient, give it a short timeout, and return a safe fallback when it fails:

function example_get_payload() {
	$cached = get_transient( 'example_api_payload' );
	if ( false !== $cached ) {
		return $cached;
	}

	$response = wp_remote_get( 'https://api.example.com/v1/data', array( 'timeout' => 2 ) );
	if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
		return array();
	}

	$data = json_decode( wp_remote_retrieve_body( $response ), true );
	$data = is_array( $data ) ? $data : array();
	set_transient( 'example_api_payload', $data, 15 * MINUTE_IN_SECONDS );

	return $data;
}

Checked on 15 November 2026 (syntax verified with php -l on PHP 8.5). Replace the URL and key with your own. For a whole-site view, WP_HTTP_BLOCK_EXTERNAL in wp-config.php blocks outgoing requests to everything except localhost and your own site, and WP_ACCESSIBLE_HOSTS lets you allow specific hosts, with wildcards supported. Try it on staging to see which features break. The full approach, including the pre_http_request filter and background refresh, is in our guide to reducing external HTTP requests.

Tweak 10: Cache HTML at the edge

A CDN that only serves images and scripts does nothing for TTFB, because the HTML still comes from your origin. To lower it for visitors far from your server, the HTML itself has to be cached close to them. Cloudflare’s Automatic Platform Optimization (APO) does that for WordPress. Its documentation says it caches dynamic content such as HTML at the edge, removes round trips to the origin and needs the Cloudflare WordPress plugin.

The same page lists what APO will not cache: logged-in and administrator requests, anything with a bypass cookie, non-GET requests, URLs with query strings outside a short marketing allowlist, and pages the plugin marks as not cacheable. Its query parameter reference lists the bypass cookie prefixes, including wp-, wordpress, comment_ and woocommerce_. In short, an edge cache fixes anonymous TTFB for distant visitors and leaves the logged-in path to your origin. Other CDNs and hosts offer full-page edge caching too. The questions are the same: what is cached, for whom and how it is purged.

curl -svo /dev/null -A "CF" 'https://example.com/' -H 'accept: text/html' 2>&1 | grep 'cf-cache-status\|cf-edge\|cf-apo-via'

Checked on 15 November 2026 against Cloudflare’s verification steps. A working APO setup returns cf-cache-status HIT, a cf-apo-via header and cf-edge-cache with platform=wordpress. Always send the Accept: text/html header when testing, because Cloudflare says a request without it is judged by URL path instead and can give a different result.

Tweak 11: Fix the hosting limits you cannot tune around

Some TTFB problems are capacity, not code. When PHP workers are all busy, new requests wait in a queue before WordPress even starts, and that wait counts toward TTFB. You see it as a site that is fast when idle and slow under a modest burst of traffic, and as TTFB that varies a lot between identical requests.

  • Compare a static file and an uncached page during a busy period. If the static file is fine and the PHP page is slow, workers or CPU are the likely limit.
  • Check how many PHP-FPM workers your plan allows and how much memory one worker uses. A common rule of thumb is memory available to PHP divided by average worker size, but read your host’s own limits first.
  • Ask your host for the slow log or an application performance view. A host that cannot show you any of this makes diagnosis harder.
  • Put the server in the region closest to most of your logged-in users, because the edge cache cannot help them.

We do not rank hosts here, because a fair comparison needs dated tests. If tweaks 1 to 10 are done and the uncached path is still slow, the next lever is a plan with more PHP workers, memory or database capacity.

Tweak 12: Remove redirects and slow connection setup

Because TTFB starts counting from navigation, anything before the server responds is part of it. web.dev lists redirect time, DNS lookup and the connection and TLS handshake as parts of the total. A chain such as http to https to www to a trailing slash can add several round trips before WordPress gets a request.

  • Link internally to the final URL, with https and the canonical host, so visitors do not take redirects at all.
  • Collapse redirect chains to a single hop at the web server, not in a plugin that runs after PHP has started.
  • Check that TLS 1.3 and HTTP/2 or HTTP/3 are on at your server or CDN.
  • Do not rely on a CDN to hide a slow origin. Fix the origin first, then add the edge.

Common mistakes people report

These come from public threads and issue trackers, paraphrased, with the date each was checked on 15 November 2026.

  • Writing to the database directly and leaving stale cache. A site owner in the Redis Object Cache support forum (about May 2026) deleted rows from wp_posts with a raw query and kept seeing the posts until the Redis cache was cleared. The plugin author pointed to wp_delete_post() and clean_post_cache(). Use WordPress functions for writes so the cache is cleared with them.
  • Page cache cleared on every small change. A WP Super Cache thread (about July 2026) describes a site with 3,000+ cached pages where an update wiped the whole cache even with the clear-all option unchecked. Support suggested turning on the plugin’s debug log to find what was triggering the purge. If your hit rate is low, look for another plugin firing a full purge.
  • Cloudflare APO showing old content after an update. Two GitHub issues on the Cloudflare plugin, one from 2021 and one from 2022, describe edge content not refreshing after a publish, in one case only for desktop visitors when cache by device type was on. Both are closed, but they are a reminder to test a purge after setup.
  • Reading APO test results wrongly. Cloudflare’s own APO FAQ answers repeated questions about BYPASS and DYNAMIC: browser DevTools with Disable cache ticked sends Cache-Control: no-cache, and tools that omit the Accept header can be judged differently. Test with a plain curl and an Accept: text/html header.
  • Autoload bloat nobody notices. The WordPress core team documented in its autoload developer note that a default of autoloading everything left many options loading on every page unnecessarily. Sites that predate WordPress 6.6 keep their old autoload values, so check the total even on a site that looks healthy.

Which tweak first? A priority table

Order by what your measurements show. This table is a starting point for a site with mostly anonymous traffic.

Tweak

Helps which request

Effort

How to verify

1. Page caching

Anonymous, cached

Low

Cache header shows a hit; TTFB drops on the second request

2. Cache bypass rules

Anonymous, cached

Medium

Hit ratio from logs; missed requests no longer share one cookie

3. Object cache

Uncached, logged-in

Low to medium

wp redis status; fewer queries in Query Monitor

4. Supported PHP

Uncached, logged-in

Low

Same page, uncached TTFB before and after on staging

5. OPcache sizing

Uncached, logged-in

Low

Status page: free memory and cached scripts below limits

6. Autoload trim

Uncached, logged-in

Medium

Total autoload bytes before and after

7. Slow queries

Uncached, logged-in

Medium to high

Query Monitor slow count; slow log entries

8. Plugin bootstrap

Uncached, logged-in

Medium

Uncached TTFB with the plugin off, on staging

9. External HTTP calls

Uncached, logged-in

Medium

HTTP API Calls panel is empty on page load

10. Edge HTML cache

Anonymous, distant visitors

Low

Edge cache header shows a hit from another region

11. Hosting capacity

All, under load

Varies

TTFB stays flat as concurrent requests rise

12. Redirects and TLS

All

Low

curl phase times; one hop to the final URL

Frequently asked questions

What is a good TTFB for WordPress?

web.dev treats 0.8 seconds or less as good and more than 1.8 seconds as poor. Lighthouse fails its server response time audit above 600 ms. For a WordPress site we aim for a cached page well under half a second from the edge and an uncached page under 600 ms. Those last two figures are our own targets, not a standard.

Does TTFB affect SEO?

TTFB is not one of the Core Web Vitals, so it is not scored directly. It sits upstream of Largest Contentful Paint, which is, because the page cannot paint before the HTML arrives. Improving TTFB helps SEO only to the extent it improves LCP and the real experience of your visitors.

Why is TTFB high only when I am logged in?

Page caches and edge caches skip logged-in requests on purpose, so you are seeing the uncached path. PageSpeed Insights and most lab tools never log in, which is why they do not show it. Work on tweaks 3 to 9, because those make the uncached request cheaper.

Will a caching plugin alone fix my TTFB?

It fixes cached anonymous requests and nothing else. Checkout, account pages, search results and anything with a query string or a bypass cookie still run PHP and MySQL, so measure those separately.

Does a CDN lower TTFB?

Only if it caches your HTML. A CDN that serves static files leaves TTFB for the page unchanged. With full-page edge caching, such as Cloudflare APO, anonymous visitors get HTML from a nearby location, while logged-in requests still go to your origin.

Start with the three measurements, fix whichever one is slow, and change one setting at a time so you know what moved the number. Plugin versions and PHP support windows change, so recheck the dated figures above before you rely on them.

Part of the Wbcom Designs family

The all-in-one WordPress community stack

Also ours: wbcomdesigns.comvapvarun.combrndle.com