TutorialsAugust 4, 20265 min read

How to Speed Up WordPress on a VPS with Caching

Layered caching is the single biggest WordPress speed win. This guide sets up page cache, Redis object cache and OPcache on your VPS — with the commands.

NBy Nxeon

Caching is the highest-leverage change you can make to a WordPress site — often the difference between a sluggish page and a near-instant one. On a VPS you can layer three types of cache that shared hosting rarely lets you touch. This guide sets each one up, with commands.

Why caching works

Every uncached WordPress page load runs PHP and queries the database. Caching stores the result so repeat visits skip that work. You want three complementary layers:

  1. Page cache — serves pre-built static HTML to logged-out visitors.
  2. Object cache (Redis) — caches repeated database query results.
  3. OPcache — keeps compiled PHP bytecode in memory.

Together they slash time-to-first-byte and let your server handle far more traffic. If you haven't installed WordPress yet, start with how to install WordPress on a VPS (LEMP stack).

Layer 1: Page cache

The biggest win. For logged-out visitors, serve cached HTML instead of running PHP at all. You can use Nginx FastCGI caching or a plugin. FastCGI cache lives in your Nginx server block:

fastcgi_cache_path /var/cache/nginx levels=1:2 keys_zone=WORDPRESS:100m inactive=60m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";

Then reference the zone in your location ~ \.php$ block. Reload Nginx to apply:

sudo nginx -t && sudo systemctl reload nginx
Deploying a new server with the Nxeon one-click deploy wizard
Deploying a new server with the Nxeon one-click deploy wizard

Layer 2: Redis object cache

Redis caches database query results in memory, speeding up dynamic and logged-in pages that skip the page cache:

sudo apt update && sudo apt install -y redis-server php-redis
sudo systemctl enable --now redis-server

Then install a Redis Object Cache plugin in WordPress and enable it — it connects WordPress to your local Redis instance automatically.

Layer 3: OPcache

OPcache compiles PHP once and keeps it in memory. Enable it in your PHP-FPM config (/etc/php/*/fpm/php.ini):

opcache.enable=1
opcache.memory_consumption=128
opcache.max_accelerated_files=10000

Restart PHP-FPM:

sudo systemctl restart php*-fpm

Beyond caching

A few extras compound the gains:

  • Serve modern image formats and lazy-load images.
  • Enable Gzip/Brotli compression in Nginx.
  • Add a CDN for static assets and global visitors.
  • Keep PHP up to date — newer versions are faster.

Fast sites also need adequate resources. If yours is starved, our best VPS for WordPress guide covers sizing, and how much RAM does a VPS need helps you right-size. Don't forget to secure the site too.

Measure before and after

Speeding up WordPress without measuring is guesswork. Establish a baseline first, then verify each change actually helped:

  • Time-to-first-byte (TTFB) is the clearest signal of server-side speed. Cache well and it should drop sharply for logged-out visitors.
  • Use a page-speed tool to see load time and identify what's slow — render-blocking assets, unoptimised images, or slow server response.
  • Test both cached and uncached paths. Logged-out pages should hit the page cache; logged-in and cart pages won't, so those tell you how fast your PHP and database really are.
  • Re-test after each layer — page cache, then Redis, then OPcache — so you know what each contributed rather than changing everything at once.

Measuring also stops you from over-optimising. Once TTFB is low and the page loads fast, further tweaks have diminishing returns, and your time is better spent elsewhere.

Common caching mistakes to avoid

Caching is powerful, but a few missteps cause the classic "why is my site showing old content?" problems:

  • Caching pages for logged-in users. Admins and logged-in members should bypass the page cache, or they'll see stale or wrong content. Good cache rules exclude them automatically.
  • Caching cart, checkout and account pages on a store — always exclude these; they're unique per user. Our WooCommerce hosting guide covers the exclusions.
  • No cache invalidation on update. When you publish a post or change a page, the relevant cache must clear so visitors see the new version. Most page-cache setups handle this automatically — confirm yours does.
  • Stacking conflicting cache plugins. Pick one caching approach and configure it well rather than layering several plugins that fight each other.
  • Forgetting the cache exists when debugging. Made a change and don't see it? Clear the cache before assuming the change failed.

Avoid these and caching is pure upside — dramatically faster pages with no downside for your users.

Where Nxeon fits

Nxeon's NVMe KVM VPS give you the fast disk and full root that make layered caching possible — Redis, OPcache and FastCGI cache all install cleanly. Start from WordPress VPS hosting or compare plans on pricing.

FAQ

What's the best caching setup for WordPress?

Layer three caches: a page cache (FastCGI or plugin) for logged-out visitors, Redis object cache for database queries, and OPcache for compiled PHP. Together they give the biggest, most reliable speed improvement.

Does Redis speed up WordPress?

Yes — Redis caches repeated database query results in memory, which speeds up dynamic and logged-in pages that bypass the page cache, such as the admin area and WooCommerce carts.

Will caching break my site?

Page caching can occasionally show stale content to logged-in users or on dynamic pages, but good cache rules exclude those. Object caching and OPcache are transparent. Test after enabling, and exclude cart/checkout pages.

How much faster will caching make WordPress?

It varies by site, but layered caching typically produces a large improvement in time-to-first-byte and lets the same server handle far more concurrent visitors — often the single biggest performance gain available.

Want a fast foundation? See WordPress VPS hosting or compare plans on pricing.

#wordpress#caching#performance#redis#vps#seobatch

Deploy your first server in under a minute

Creating an account is free and takes no card details. You pay when you deploy — choose a billing term and pay from your wallet or by card at checkout.