Why WordPress is slow, and why it’s unpredictable
WordPress builds every page on request. PHP boots WordPress, loads every autoloaded option, runs each active plugin’s hooks and queries the database, and only then sends HTML. That cost is paid on every request that a cache does not answer, and each active plugin can add a query or an external API call to that path.
The unpredictable part comes from mixing two kinds of request. A cached page comes back fast; an uncached one waits for PHP. Which kind a visitor gets depends on things they cannot see: whether the page was purged a minute ago, whether the page is one the cache may store at all, whether wp-cron picked their request to run a backup, and whether every PHP-FPM worker is busy with a crawler. A quick test from your desk can therefore look fine while customers get slow pages.
What to install
-
Page caching and optimization: the pagespeed-nginx
Docker image (
ghcr.io/we-amp/pagespeed-nginx) as a reverse proxy in front of your web server (see the Docker install guide), plus the free WeAmp Cache Control for ModPageSpeed plugin from the WordPress.org directory. Turn the plugin on in its setup wizard; it is off by default. The proxy stores anonymous pages and serves them without running PHP. The plugin marks which pages it may store and purges them on publish. -
Optimization only: the nginx or Apache package, or
the IIS module, inside the server you already run. It rewrites images, CSS and scripts but
doesn’t store pages; pair it with nginx
proxy_cache, Varnish or a CDN for page caching.
Measure first
Lab tools such as Lighthouse and PageSpeed Insights run one test from one machine. Field data, the Chrome User Experience Report, is real Chrome users at the 75th percentile over the previous 28 days. Use the lab to find causes and the field to judge results; the Core Web Vitals guide covers the thresholds (LCP 2.5 s, INP 200 ms, CLS 0.1). For a quick read of one URL, run it through the free analyzer; it needs no account.
Then split the response time into its parts. curl reports each phase as a cumulative time from the start of the request:
curl -o /dev/null -s -w \
'dns %{time_namelookup}\nconnect %{time_connect}\ntls %{time_appconnect}\nttfb %{time_starttransfer}\ntotal %{time_total}\n' \
https://example.com/a-post/
A large gap between tls and ttfb is
server time: PHP, the database or a queue in front of them. Now run the same request a
hundred times and read two percentiles:
for i in $(seq 100); do
curl -o /dev/null -s -w '%{time_starttransfer}\n' https://example.com/a-post/
done | sort -n | awk '{t[NR]=$1} END {print "p50", t[int(NR*0.50)], "p95", t[int(NR*0.95)]}'
For an inconsistent site, the gap between the two is what to read. A good p50 with a bad p95 means most requests are cached and some are not: cache misses, pages that are not cacheable, or saturated PHP workers. A bad p50 means the cache is not working at all, or the server is slow for everyone. Check the headers too, with and without a cookie:
curl -sI https://example.com/a-post/ | grep -i '^cache-control'
curl -sI -H 'Cookie: _ga=GA1.1.123.456' https://example.com/a-post/ | grep -i '^cache-control'
Run these against WordPress itself, not through the cache. Through mod_pagespeed’s
Docker proxy, read the X-PageSpeed header on a normal GET instead,
for example with
curl -s -o /dev/null -D - https://example.com/a-post/ | grep -i '^x-pagespeed'. It shows MISS, then HIT once the page
is cached. A curl -I HEAD request is never stored, so it stays on
MISS. Stock WordPress sends no
Cache-Control: public on anonymous pages, so a server cache has
nothing it may store. Most real visitors carry an analytics cookie, so the second request
shows whether the header is still there for that traffic.
Reduce server response time (TTFB) on WordPress
To reduce server response time on a WordPress site, serve anonymous pages from a full-page cache so PHP does not run, purge that cache on publish, then make the requests the cache cannot answer cheaper: add a persistent object cache, trim autoloaded options, move wp-cron to the system crontab, fix slow plugins and size PHP-FPM.
Work down this ladder in order: the first steps remove the most PHP work. Each is marked with whether mod_pagespeed does it. The longer version is in where TTFB goes and the server-layer fix.
-
1. Full-page cache for anonymous HTML mod_pagespeed with the worker
Serving a stored page skips PHP entirely, so this is the biggest single lever. With the optimizer worker set up as in What to install, the plugin adds
Cache-Control: public, max-ageto anonymous pages andno-storeto logged-in, cart, session and non-GET responses, which are then not stored. With the native module, put nginxproxy_cache, Varnish or a CDN in front. The server-side page cache post explains why the cache belongs on the server and not in PHP. -
2. Purge on publish mod_pagespeed with the worker
Without purging, lifetimes have to stay short, which means more misses. The plugin calls the purge endpoint when a post is published, updated or deleted, and on comment and stock changes, so anonymous pages can carry a longer lifetime. Which headers to set is covered in Cache-Control and purging. With the native module and a front cache, purge that cache separately.
-
3. Persistent object cache not mod_pagespeed
Every request a page cache cannot answer still runs PHP: the admin screens, carts, checkouts, cache misses. Redis or Memcached with an object-cache drop-in keeps query results between requests.
wp cache typeshows whether one is active. -
4. Autoloaded options, wp-cron and Heartbeat not mod_pagespeed
WordPress loads every autoloaded option on every uncached request. Plugins leave large ones behind, sometimes after they are removed:
# total size of everything WordPress loads on every request wp option list --autoload=on --format=total_bytes # the twenty largest autoloaded options wp option list --autoload=on --fields=option_name,size_bytes --format=csv \ | sort -t, -k2 -n -r | head -20wp-cron runs scheduled jobs inside visitor requests, so one unlucky visitor waits for a backup or a feed import. Turn it off and run it from the system crontab:
wp cron event list --fields=hook,next_run_relative,recurrence wp config set DISABLE_WP_CRON true --rawThen add this line to the web server user’s crontab, opened with
sudo crontab -u www-data -e; the web server user iswww-dataon Debian and Ubuntu:*/5 * * * * cd /var/www/example && wp cron event run --due-now --quietHeartbeat polls
admin-ajax.phpevery 15 seconds while the post editor is open, and no page cache can answer those requests. Ten editors with open tabs are a steady PHP load. On the front end it runs only when a plugin loads it. -
5. Slow plugins and queries not mod_pagespeed
Query Monitor shows the queries, hooks and HTTP calls each plugin adds to a page. Code Profiler or an APM gives time per plugin and function. The old P3 profiler is no longer maintained.
-
6. PHP-FPM sizing and OPcache not mod_pagespeed
When every FPM worker is busy, new requests queue, and the queue shows up as a p95 spike. Size
pm.max_childrento the memory you can give PHP divided by a worker’s resident size. Enable the FPM status page and watchlisten queueandmax children reached; setrequest_slowlog_timeoutto get stack traces of slow requests. Make sure OPcache is on and its memory is not full. -
7. Transport and CDN not mod_pagespeed
HTTP/2 or HTTP/3, TLS session resumption and Brotli or gzip are web server configuration. A CDN shortens the distance to far-away visitors, and it works with the server cache rather than replacing it. A CDN in front of mod_pagespeed must pass the
Acceptheader and vary on it, so each browser gets the image format it supports.
To find what is slowing a page down, analyze it (free, no account) or get the nginx Docker image.
Images
Images are usually the heaviest bytes on a WordPress page and often the LCP element.
WordPress generates sizes on upload and adds srcset, but it does
not convert formats for most themes, and images from page builders and sliders often skip
that path. mod_pagespeed works on the HTML the server sends, so it reaches every image your
own site serves, theme and plugin images included (images on other domains are left alone).
The filters:
convert_jpeg_to_webp
and
convert_jpeg_to_avif
for modern formats,
resize_images
for oversized files,
insert_image_dimensions
against layout shift, and
lazyload_images
for images below the fold. Do not lazy-load the hero image. The step-by-step versions are in
fix LCP on WordPress
and
fix CLS on WordPress. The general method is in
how to optimize images for websites.
CSS and render-blocking
Themes and plugins each enqueue their own stylesheets, and the browser paints nothing until it has downloaded all of them. mod_pagespeed has two filters for this. rewrite_css minifies the CSS. prioritize_critical_css inlines the rules the first screen needs and loads the rest later, which removes the stylesheet chain from the first paint. The optimizer worker inlines critical CSS by default. In the native module it is opt-in and marked test first, so try it on a staging copy before turning it on site-wide. Either way, check pages whose layout depends on late CSS, such as menus and sliders. Removing stylesheets a page never uses is still a plugin and theme decision.
Plugin JavaScript and INP
INP measures how long the page takes to respond to a click or tap. On WordPress the cost is usually plugin script: jQuery and its migrate shim, analytics, sliders, chat widgets and delegated click handlers that run on every interaction. mod_pagespeed can minify scripts with rewrite_javascript_external and push their execution past the first render with defer_javascript, which is test first because it changes execution order; with the optimizer worker, scripts are deferred only where browser analysis has found it safe. Neither setup can remove a handler or make one faster. For that, find the slow interaction in the DevTools Performance panel, then replace or remove the plugin behind it. The full method is in fix INP on WordPress.
Reduce article page load times
To reduce article page load times, make sure anonymous readers get a cache hit, and that publishing and comments purge the page instead of shortening its lifetime. Then look at what the article itself carries: large inline images, video embeds above the fold, a related-posts block that runs its own query, and ad or share scripts. Run the percentile loop above on a post URL, not only the home page, since posts are where most search traffic lands.
Improve conversions on a slow WordPress site: measure first
Speed affects conversions through the visitors who leave before a page is usable. How much it matters on your site has to be measured. Record field LCP, TTFB and the conversion rate, make one change, and compare a 28-day field window before and after. For a cleaner comparison, hold back a set of URLs with the plugin’s excluded URL patterns and use them as a control.
Cart and checkout responses are marked no-store, so those pages are never cached. If checkout is slow, the cause is PHP, a plugin or the hosting, and the object cache and PHP-FPM steps above are where to look.
What mod_pagespeed does and doesn’t fix
mod_pagespeed works at the web server, below WordPress. That covers the bytes a page sends and, with the optimizer worker, the page cache in front of PHP. It does not change what PHP does when it runs.
| Problem | mod_pagespeed | Notes |
|---|---|---|
| Full-page cache for anonymous HTML | With worker | Yes with the optimizer worker: it caches full HTML pages in front of PHP once the WordPress plugin marks them public. No with the native module (the nginx or Apache package, IIS); add a front cache. |
| Purge on publish | With worker | With the optimizer worker, the WordPress plugin calls the purge endpoint on publish, update, delete, comment and stock changes and the stored pages are dropped. With the native module the same calls evict optimized images, CSS and JavaScript, not pages; a front cache needs its own purge. |
| Images: WebP, AVIF, resizing, dimensions, lazy-loading | Yes | Applied at the server to the images your own site serves, theme and plugin images included; images hosted on other domains are left alone. |
| Render-blocking CSS | Yes | Minification, on by default. Critical CSS is on by default with the worker, and opt-in and test first in the native module. |
| Plugin JavaScript and INP | Partly | Minifies and can defer scripts; with the optimizer worker, only where browser analysis has found it safe. It cannot remove a plugin’s event handlers or make them faster. |
| Object cache | No | Install Redis or Memcached with an object-cache drop-in. |
| Autoloaded options, wp-cron, admin-ajax and Heartbeat | No | WordPress configuration and plugin choices; see the fix ladder above. |
| Slow plugins and database queries | No | Find them with Query Monitor, Code Profiler or an APM, then replace or fix them. |
| PHP-FPM sizing and OPcache | No | PHP configuration on your server. |
| Cart, checkout and account pages | No | Their responses are marked no-store and are not stored, on purpose. Their speed is PHP, plugins and hosting. |
| Overloaded or shared hosting | No | A noisy neighbour or an undersized plan needs a different host or plan. |
Common questions
- Why is my WordPress site slow only sometimes?
- Because some requests hit a cache and some run PHP. Cache misses after a purge or expiry, pages marked no-store such as cart and checkout, wp-cron jobs running inside a visitor request, and PHP-FPM workers all busy with bots or editors each produce slow outliers. Compare TTFB at p50 and p95: a good median with a bad p95 points at misses, uncacheable pages or saturation, not at the theme.
- What is a good TTFB for WordPress?
- Google rates a time to first byte of 0.8 seconds or less at the 75th percentile as good. For a WordPress page served from a full-page cache, TTFB should sit close to the network round trip; if it does not, the page is not being cached. Measure the uncached PHP render time separately, because that is what every cache miss and every no-store page, such as cart and checkout, costs.
- Do I need a caching plugin if the server caches?
- You do not need a second page cache in PHP; two page caches stacked make purging harder. You do need something that tells the server which pages are cacheable and purges them when content changes. WordPress sends no Cache-Control: public on anonymous pages, so without that the server cache has nothing it may store. With mod_pagespeed and the optimizer worker, the free WordPress plugin sets those headers and sends the purges; the worker does the caching.
- How do I reduce server response time on a WordPress site?
- Serve anonymous pages from a full-page cache so PHP does not run (with mod_pagespeed, that is the optimizer worker), purge that cache on publish, then make the requests the cache cannot answer cheaper: add a persistent object cache, trim autoloaded options, move wp-cron to the system crontab, fix slow plugins and size PHP-FPM.
- Which plugins slow WordPress down?
- The usual culprits are plugins that run work on every request: page builders that load their assets sitewide, related-posts and statistics plugins that query or write the database on every view, social plugins that call external APIs, security plugins that log each request to the database, and plugins that store large autoloaded options. Query Monitor or Code Profiler shows which ones cost time on your site.
- Does page speed affect conversions?
- It can, because a faster first paint and response keep more visitors on the page long enough to act, but the size of the effect depends on your site. Measure it: record field LCP, TTFB and conversion rate, make one change, and compare a 28-day field window before and after. Hold back a set of URLs from caching as a control if you want a cleaner comparison.
Start with a measurement
Run a page through the analyzer to see what is slowing it down. For server-side page caching, run mod_pagespeed’s nginx Docker image as a reverse proxy in front of WordPress, then add the WordPress plugin so anonymous pages are cached and purged on publish. The nginx and Apache packages optimize pages but don’t cache them. mod_pagespeed is open source under the Apache License 2.0.
Need help with a rollout? See the support options.
See also:
- The WordPress plugin: cache headers and purge on publish
- Server-side page caching for WordPress
- Reduce TTFB at the server layer
- PageSpeed optimization: every optimization by resource type, and which a server applies
- Core Web Vitals: LCP, CLS and INP by platform
- Cache-Control and purging
WordPress is a trademark of the WordPress Foundation. We-Amp B.V. is not affiliated with or endorsed by the WordPress Foundation.