---
title: "Speed up WordPress on your own server · CloudSat"
description: "Speed up WordPress on a VPS: measure response times, add an Nginx page cache and a Redis object cache, tune OPcache, PHP-FPM and MariaDB, and fix WP-Cron."
url: https://cloudsat.io/learn/speed-up-wordpress-on-your-own-server
updated: 2026-11-18T12:00:00Z
source: CloudSat (https://cloudsat.io/). Prices in USD.
---

[Self-hosting](https://cloudsat.io/learn/topic/self-hosting)

# Speed up WordPress on your own server

Speed up WordPress on a VPS: measure response times, add an Nginx page cache and a Redis object cache, tune OPcache, PHP-FPM and MariaDB, and fix WP-Cron.

CloudSat team November 18, 2026 7 min read

On your own server, a slow WordPress site is almost always doing too much work per request: running PHP for pages that could come from a cache, asking the database the same questions on every load, or waiting on a plugin. The fixes below follow the order that pays off fastest. Measure first, cache whole pages, cache database results, then tune PHP and MariaDB for the memory you actually have. The examples assume Nginx and PHP 8.3 on Ubuntu 24.04; paths change with other versions.

## Measure before you change anything

Time to first byte (TTFB) is the clearest server-side number: how long the server takes to start answering. Measure it from outside the server, several times, for an anonymous visitor:

```bash
for i in 1 2 3 4 5; do
  curl -o /dev/null -s -w 'ttfb %{time_starttransfer}s total %{time_total}s\n' https://example.com/
done
```

Then look inside. The Query Monitor plugin shows, for any page, the slow database queries, the plugin each query came from, and outbound HTTP calls that block rendering. Turn on MariaDB's slow query log for a day to catch what happens when you are not watching:

```ini
# /etc/mysql/mariadb.conf.d/90-slow.cnf
[mysqld]
slow_query_log = 1
slow_query_log_file = /var/log/mysql/slow.log
long_query_time = 1
```

Write the numbers down. Every change below should move one of them, and a change that does not is a change to undo. The pattern of the numbers also tells you where to start:

| What you see | Likely cause | Start with |
| --- | --- | --- |
| High TTFB for every anonymous page | PHP renders each page from scratch | Page cache |
| Fast for visitors, slow when logged in or in the shop | Repeated database queries | Object cache, Query Monitor |
| One page much slower than the rest | A plugin, query or external call on that page | Query Monitor on that page |
| Slow even for images and CSS | Network, disk or an overloaded server | Server load with `top`, then static file rules |

## Cache whole pages for anonymous visitors

Most visitors are not logged in, and for them a page is the same for minutes at a time. Nginx can store the rendered HTML and serve it without starting PHP. In the `http` context, for example in `/etc/nginx/conf.d/fastcgi-cache.conf`:

```nginx
fastcgi_cache_path /var/cache/nginx/wp levels=1:2 keys_zone=wp:50m max_size=1g inactive=60m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
```

Then in the site's server block:

```nginx
set $skip_cache 0;
if ($request_method = POST) { set $skip_cache 1; }
if ($query_string != "") { set $skip_cache 1; }
if ($request_uri ~* "/wp-admin/|/wp-login.php|/wp-json/|/cart/|/checkout/|/my-account/") { set $skip_cache 1; }
if ($http_cookie ~* "wordpress_logged_in|comment_author|wp-postpass|woocommerce_items_in_cart") { set $skip_cache 1; }

location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/run/php/php8.3-fpm.sock;
    fastcgi_cache wp;
    fastcgi_cache_valid 200 301 10m;
    fastcgi_cache_bypass $skip_cache;
    fastcgi_no_cache $skip_cache;
    fastcgi_cache_use_stale error timeout updating;
    add_header X-Cache $upstream_cache_status;
}
```

Logged-in users, comment authors, carts and checkouts always reach PHP, and everyone else gets a copy at most ten minutes old. A short lifetime like this avoids the hardest part of page caching, which is purging the right pages when content changes. `fastcgi_cache_use_stale` keeps serving the last good copy if PHP fails, so a brief upstream error does not become an outage. Nginx never caches a response that sets a cookie, and `Cache-Control` or `Expires` headers sent by PHP take priority over `fastcgi_cache_valid`, so a plugin that sends either to anonymous visitors keeps every request a `MISS`. Check it works:

```bash
curl -sI https://example.com/ | grep -i x-cache
```

The first request shows `MISS`, the next `HIT`. If you prefer the cache managed from the dashboard, a caching plugin can do the same job, and OpenLiteSpeed with its cache plugin does it without any Nginx configuration.

## Add a persistent object cache

Page caching does nothing for logged-in users, the admin area or a shop's cart. For those, a persistent object cache keeps the results of repeated database queries in memory between requests. Install Redis and the PHP extension, then the Redis Object Cache plugin:

```bash
sudo apt install -y redis-server php8.3-redis
sudo systemctl restart php8.3-fpm
cd /var/www/example.com
sudo -u www-data wp config set WP_REDIS_PREFIX example: --type=constant
sudo -u www-data wp plugin install redis-cache --activate
sudo -u www-data wp redis enable
sudo -u www-data wp redis status
```

The prefix keeps keys apart if several sites share one Redis instance. Redis listens only on `127.0.0.1` by default; keep it that way. Valkey, the open-source fork of Redis, says existing Redis clients connect to it without code changes, so the same settings apply if you run it instead.

## Tune OPcache

OPcache keeps compiled PHP in memory and is enabled by default, but its defaults are sized for a small site. A large plugin set can overflow it, after which PHP recompiles files on every request. In `/etc/php/8.3/fpm/conf.d/90-opcache.ini`:

```ini
opcache.memory_consumption = 256
opcache.interned_strings_buffer = 16
opcache.max_accelerated_files = 20000
opcache.revalidate_freq = 60
```

`revalidate_freq` makes PHP check files for changes once a minute instead of every two seconds. WordPress clears OPcache for the files its own updates replace; a file you edit by hand can take up to a minute to show.

## Size PHP-FPM for the memory you have

Each PHP-FPM worker handles one request at a time. Too few workers and requests queue; too many and the server swaps. Measure the average worker size under real traffic, then set the pool in `/etc/php/8.3/fpm/pool.d/www.conf`:

```ini
pm = dynamic
pm.max_children = 12
pm.start_servers = 3
pm.min_spare_servers = 2
pm.max_spare_servers = 4
pm.max_requests = 500
```

Here `12` assumes about 1 GB for PHP and workers of about 80 MB; compute yours as memory for PHP divided by the average worker size. `pm.max_requests` recycles workers regularly, which caps slow memory leaks in plugins. The [guide to 502 and 504 errors](https://cloudsat.io/learn/fix-502-504-and-505-errors-behind-nginx) shows how to measure worker memory and what a pool that is too small looks like in the logs.

PHP renders each request on a single core, so clock speed shows up directly in uncached response times. That is the case for a [High Frequency VPS](https://cloudsat.io/high-frequency-vps) over simply adding cores.

## Give MariaDB memory and trim autoloaded options

InnoDB serves reads from its buffer pool. If the pool is smaller than the hot data, every page view touches the disk. Check the database's size, then give the pool room for it, within the memory left after PHP:

```bash
sudo mariadb -e "SELECT ROUND(SUM(data_length + index_length) / 1048576) AS mb FROM information_schema.tables WHERE table_schema = 'wordpress';"
```

```ini
# /etc/mysql/mariadb.conf.d/90-tuning.cnf
[mysqld]
innodb_buffer_pool_size = 512M
```

Then look at autoloaded options, which WordPress loads on every request. Plugins that store large blobs there slow every page, cached or not by the object cache, and Site Health marks a total above about 800 KB as critical. List the largest:

```bash
cd /var/www/example.com
sudo -u www-data wp db query "SELECT option_name, LENGTH(option_value) AS bytes FROM $(sudo -u www-data wp db prefix)options WHERE autoload IN ('yes','on','auto-on','auto') ORDER BY bytes DESC LIMIT 10"
```

Rows left behind by plugins you removed can usually go, after a database export; for anything else, check with the plugin that owns it first.

## Move WP-Cron to the system scheduler

By default WordPress checks for scheduled tasks during page loads, so a visitor pays for your backups and newsletters. Disable that and let cron run due events every five minutes:

```bash
sudo -u www-data wp config set DISABLE_WP_CRON true --raw
echo '*/5 * * * * cd /var/www/example.com && /usr/local/bin/wp cron event run --due-now > /dev/null 2>&1' | sudo crontab -u www-data -
```

That second command replaces the `www-data` crontab, so append the line by hand with `sudo crontab -u www-data -e` if it already has entries.

## Serve static files well

Let browsers keep assets, and compress text:

```nginx
location ~* \.(?:css|js|woff2|svg|png|jpe?g|gif|webp|avif|ico)$ {
    expires 30d;
    access_log off;
}
```

Ubuntu's Nginx enables gzip but only for HTML; add `gzip_types text/css application/javascript application/json image/svg+xml;` in `nginx.conf`. With Nginx 1.24, HTTP/2 is turned on per listener with `listen 443 ssl http2;`. Upload images in WebP or AVIF and at the size they are displayed: a 4 MB hero photo costs more time than any server setting can win back.

## FAQ

### Do I still need a caching plugin?

Not for page caching if Nginx does it. Plugins remain useful for front-end work such as combining assets, delaying scripts and generating image formats, so pick one for those features and leave its page cache off.

### Will the page cache break a WooCommerce cart?

Not with the rules above: cart, checkout and account pages, and any visitor with items in the cart, bypass the cache. Test by adding a product in a private window and checking `X-Cache` on the next pages.

### Why is the admin area still slow?

The admin area is never page-cached, so it shows the raw cost of PHP, the database and every active plugin. An object cache helps the most. Then open Query Monitor on the slow screen: a single plugin running heavy queries or calling an outside API on every admin page is the usual finding.

### Does a CDN replace server-side caching?

No. A CDN shortens the distance for static files and cached pages, but every uncached request still reaches your server, and that is where the work above pays off.

**Run it on CloudSat.** Cloud VPS on AMD EPYC and NVMe from $1.98/mo in 13 regions, delivered in under 5 minutes and paid in crypto. [See plans](https://cloudsat.io/plans) or [deploy a server](https://dash.cloudsat.io/console/deploy).

## Keep reading

[All guides in Self-hosting](https://cloudsat.io/learn/topic/self-hosting)

- [Install WordPress on a VPS with Nginx and MariaDB](https://cloudsat.io/learn/install-wordpress-on-a-vps-with-nginx): Self-hosting Install WordPress on a VPS with Nginx and MariaDB 7 min read
- [Manage WordPress over SSH with WP-CLI](https://cloudsat.io/learn/manage-wordpress-over-ssh-with-wp-cli): Self-hosting Manage WordPress over SSH with WP-CLI 7 min read
- [Fix 502, 504 and 505 errors behind an Nginx reverse proxy](https://cloudsat.io/learn/fix-502-504-and-505-errors-behind-nginx): DevOps Fix 502, 504 and 505 errors behind an Nginx reverse proxy 7 min read
- [Set up 301 redirects in WordPress: server, plugin or code](https://cloudsat.io/learn/set-up-301-redirects-in-wordpress): Self-hosting Set up 301 redirects in WordPress: server, plugin or code 6 min read
