Back to all articles
WordPress2026-07-07

Optimize WordPress with KVM

How to optimize WordPress with KVM: Nginx page cache, Redis, and WebP images on an NVMe VPS, instead of shared hosting.

Optimizing WordPress on a KVM server with NVMe means running the site on an isolated virtual machine, with Nginx page cache, Redis for repeated queries, and WebP images.

WordPress is the most popular platform in the world for creating websites and portals. However, if not optimized correctly, excessive plugins and heavy databases can slow down the user experience, which directly affects your Google ranking (Core Web Vitals) and your lead conversion rate.

Below, we list the main optimizations to guarantee maximum speed for your WordPress.

1. Choose the Right Infrastructure (Managed Hosting)

Most WordPress slowness starts at the hosting server. Cheap shared hosting plans do not have enough dedicated resources to process dynamic PHP requests quickly.

Solution:

  • Host WordPress on a KVM VPS with NVMe disk. KVM isolates CPU and memory from other sites. NVMe does the read and write in milliseconds. See the plans on the hosting page.
  • Use a server configured with LiteSpeed or Nginx as a reverse proxy to process static requests much faster than traditional Apache.

2. Implement Page and Object Caching

WordPress generates pages dynamically by querying the database via PHP for each visit. Caching saves a static version (HTML) of each page, delivering it instantly to subsequent visitors.

What to configure:

  • Page Cache: Plugins like LiteSpeed Cache or WP Rocket save static versions of pages.
  • Object Cache: Configuring Redis or Memcached on the server allows saving repetitive database queries in RAM, reducing loading time (Time to First Byte - TTFB).

3. Image Optimization and Lazy Loading

Heavy images are the main culprits in bandwidth consumption on visitors' mobile phones.

How to optimize:

  • Convert all images to modern, compressed formats like WebP or AVIF.
  • Ensure the lazy loading attribute (loading="lazy") is active on all images below the page fold, avoiding loading media that the visitor has not yet viewed.

4. Nginx and Redis on the server

A cache plugin does not replace the cache in front of PHP. fastcgi_cache_path belongs in the http block, outside any server. The rest belongs in the site's server block. Pasting both into the same block makes nginx -t fail. Skip the cache for the admin area, logged-in users, and form posts. Anonymous HTML stays for 60 minutes.

In http:

fastcgi_cache_path /var/cache/nginx/wordpress levels=1:2 keys_zone=WORDPRESS:100m inactive=60m;

In the site server:

set $skip_cache 0;
if ($request_method = POST) { set $skip_cache 1; }
if ($query_string != "") { set $skip_cache 1; }
if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*\.php") { set $skip_cache 1; }
if ($http_cookie ~* "comment_author|wordpress_logged_in|wp-postpass") { set $skip_cache 1; }

location ~ \.php$ {
    include fastcgi_params;
    fastcgi_pass unix:/run/php/php8.3-fpm.sock;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_cache WORDPRESS;
    fastcgi_cache_key "$scheme$request_method$host$request_uri";
    fastcgi_cache_valid 200 60m;
    fastcgi_cache_bypass $skip_cache;
    fastcgi_no_cache $skip_cache;
    add_header X-Cache-Status $upstream_cache_status;
}

Check the PHP socket with ls /run/php. The header X-Cache-Status: HIT on the second anonymous visit means the page did not go back to the database.

Redis holds the object cache. On Ubuntu:

sudo apt install -y redis-server
sudo systemctl enable --now redis-server
cd /var/www/html
sudo -u www-data wp plugin install redis-cache --activate
sudo -u www-data wp redis enable
sudo -u www-data wp redis status

In wp-config.php, before "That's all, stop editing!":

define('WP_REDIS_HOST', '127.0.0.1');
define('WP_CACHE', true);

wp redis status must show Status: Connected. Redis listens only on 127.0.0.1. Do not open port 6379 on the firewall.

When the page never leaves PHP

  • A second anonymous request without X-Cache-Status: HIT is almost always a login cookie or a query string. Test in a private window, on the URL with no ?.
  • nginx -t naming fastcgi_cache_path inside server means the first block landed in the wrong place. It belongs in http.
  • wp redis status other than Connected means Redis is stopped or WP_REDIS_HOST points somewhere else. ss -ltnp | grep 6379 must show 127.0.0.1.

Conclusion

Having a fast site is essential to retain visitors and close sales in the B2B digital environment. By structuring your WordPress under managed hosting with appropriate caching and optimized images, your site will load instantly, improving your SEO and generating many more leads.

Common questions

How do I optimize WordPress on a KVM VPS?

Run WordPress on an isolated KVM VPS with NVMe, cache anonymous pages in Nginx, keep repeated queries in Redis, and serve images as WebP. On shared hosting the same plugins stay slow because the CPU is shared.

What does a KVM server change for WordPress?

KVM gives the site its own CPU and memory. NVMe reads the database and files in milliseconds. The cache in front of PHP skips rebuilding the page on every visit.

WordPress hosting on NVMe

A fast WordPress site starts on the server. Hosting with NVMe, daily backup, and SSL.

See hosting