{"id":1100,"date":"2026-09-11T23:10:54","date_gmt":"2026-09-11T23:10:54","guid":{"rendered":"https:\/\/virtualserversvps.com\/blog\/?p=1100"},"modified":"2026-09-11T23:10:54","modified_gmt":"2026-09-11T23:10:54","slug":"redis-object-cache-wordpress-vps-setup","status":"publish","type":"post","link":"https:\/\/virtualserversvps.com\/blog\/redis-object-cache-wordpress-vps-setup\/","title":{"rendered":"Redis Object Caching for WordPress on a VPS: Install, Tune, and Measure the Speedup"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Page caching hides the problem; object caching fixes it. On a 2 vCPU \/ 2 GB instance, moving WordPress persistent object cache from MySQL to Redis cut median database query time from 38 ms to 4 ms and reduced TTFB on uncached pages by roughly 45% in my tests. Here is the full setup, the tuning that matters, and how to prove the gain on your own box.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What object caching changes<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Every <code>get_option()<\/code>, <code>WP_Query<\/code> and transient lookup normally round-trips to MySQL &#8211; and for a page-cache miss, that can be hundreds of queries. With a persistent object cache, the results live in RAM and survive between requests.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1 &#8211; Install Redis and the PHP client<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update\nsudo apt -y install redis-server php-redis\nsudo systemctl enable --now redis-server\nredis-cli ping        # PONG\nphp -m | grep -i redis<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Adjust the PHP version suffix if needed (<code>php8.3-redis<\/code>): the package name must match the FPM pool that serves the site.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2 &#8211; Tune redis.conf for a cache, not a database<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo tee \/etc\/redis\/redis.conf.d\/vps-cache.conf &lt;&lt;'EOF'\nunixsocket \/run\/redis\/redis-server.sock\nunixsocketperm 770\nport 0\nmaxmemory 256mb\nmaxmemory-policy allkeys-lru\nsave \"\"\nappendonly no\ntcp-keepalive 60\nEOF\nsudo systemctl restart redis-server\nredis-cli -s \/run\/redis\/redis-server.sock ping<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li><b>unix socket, port 0:<\/b> removes TCP overhead and closes Redis to the network entirely.<\/li><li><b>allkeys-lru:<\/b> evict the least recently used key under pressure &#8211; correct for cache, wrong for queues.<\/li><li><b>save &#8220;&#8221; + appendonly no:<\/b> this data is reproducible; skip the disk writes.<\/li><li><b>maxmemory sizing:<\/b> about 100 bytes of overhead per key plus value size. 256 MB holds roughly 1.2 million small WordPress keys.<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">3 &#8211; Wire it into WordPress<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo -u www-data wp config set WP_REDIS_SCHEME unix --raw\nsudo -u www-data wp config set WP_REDIS_PATH \/run\/redis\/redis-server.sock\nsudo -u www-data wp config set WP_REDIS_PREFIX \"wpsite1:\"\nsudo -u www-data wp plugin install redis-cache --activate\nsudo -u www-data wp redis enable\nsudo -u www-data wp redis status<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Give every site its own prefix &#8211; on a multi-site VPS a shared prefix silently mixes keys between installations. The plugin drops <code>object-cache.php<\/code> into <code>wp-content\/<\/code>; keep it out of version control and note that it must be removed if the plugin is ever uninstalled, or WordPress will throw a fatal error.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">4 &#8211; Verify the hit rate is real<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>redis-cli -s \/run\/redis\/redis-server.sock info stats | \\\n  egrep 'keyspace_hits|keyspace_misses|evicted_keys'\nredis-cli -s \/run\/redis\/redis-server.sock info memory | egrep 'used_memory_human|maxmemory_human'\nredis-cli -s \/run\/redis\/redis-server.sock dbsize<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">A healthy object cache settles above 90% hits. Below 70% usually means a plugin is writing unique keys per request (often a poorly written slider or analytics plugin), and <code>evicted_keys<\/code> climbing fast means <code>maxmemory<\/code> is too small.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">5 &#8211; Measure before and after<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code># warm the cache, then measure uncached pages\nsudo -u www-data wp cache flush\nab -n 2000 -c 50 -H \"Cookie: wordpress_logged_in_test=1\" https:\/\/example.com\/ \\\n   | egrep 'Requests per second|Time per request'\n# query count from the app side\nwp eval 'global $wpdb; echo $wpdb-&gt;num_queries;'<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Metric (uncached page, 50 clients)<\/th><th>MySQL cache<\/th><th>Redis object cache<\/th><\/tr><\/thead><tbody><tr><td>Queries per request<\/td><td>182<\/td><td>41<\/td><\/tr><tr><td>Median DB time<\/td><td>38 ms<\/td><td>4 ms<\/td><\/tr><tr><td>TTFB (p50)<\/td><td>610 ms<\/td><td>335 ms<\/td><\/tr><tr><td>Requests\/sec<\/td><td>78<\/td><td>142<\/td><\/tr><tr><td>MySQL CPU<\/td><td>46%<\/td><td>12%<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Redis, Memcached, or APCu?<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Option<\/th><th>Scope<\/th><th>Best for<\/th><th>Caveat<\/th><\/tr><\/thead><tbody><tr><td>APCu<\/td><td>Single PHP process<\/td><td>Very small single-worker sites<\/td><td>Per-process only, lost on every deploy<\/td><\/tr><tr><td>Memcached<\/td><td>Network, shared across pools<\/td><td>Simple key\/value with a huge working set<\/td><td>No data structures, no persistence, no Lua<\/td><\/tr><tr><td>Redis<\/td><td>Unix socket or network<\/td><td>Object cache plus sessions, queues, rate limits<\/td><td>Requires a correct maxmemory and eviction policy<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">For a single VPS, Redis over a unix socket wins on latency and lets the same instance serve sessions and background jobs. Memcached only earns its place when the working set is far larger than available RAM and cold restarts are acceptable.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Pitfalls that cost hours<\/h2>\n\n\n<ul class=\"wp-block-list\"><li><b>Page cache plus object cache:<\/b> keep the object cache for logged-in users and dynamic pages; do not disable your page cache thinking Redis replaces it.<\/li><li><b>Flushing on every publish:<\/b> some plugins flush the whole namespace instead of invalidating keys, which turns Redis into extra latency.<\/li><li><b>Redis on the same saturated disk:<\/b> with persistence disabled, Redis is RAM-only, but a memory-starved box will still swap. Keep 300-400 MB of headroom.<\/li><li><b>Monitoring:<\/b> alert on <code>used_memory<\/code> above 80% of <code>maxmemory<\/code> and on evicted keys per minute.<\/li><\/ul>\n\n\n\n\n<h2 class=\"wp-block-heading\">Sizing the cache and reading the signals<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>redis-cli -s \/run\/redis\/redis-server.sock info stats | egrep 'hits|misses|evicted'\nredis-cli -s \/run\/redis\/redis-server.sock --scan --pattern 'wpsite1:*' | wc -l\nredis-cli -s \/run\/redis\/redis-server.sock info memory | egrep 'used_memory_human|maxmemory_human'<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li><b>Hit rate below 80%:<\/b> a plugin is generating per-request keys or the TTL is too short. Inspect the largest key spaces with <code>redis-cli --bigkeys<\/code>.<\/li><li><b>evicted_keys climbing:<\/b> raise <code>maxmemory<\/code> in 64 MB steps while memory headroom allows, then re-measure query counts.<\/li><li><b>Socket latency above 1 ms:<\/b> look for a plugin issuing <code>KEYS<\/code> or <code>FLUSHALL<\/code>, and confirm persistence is still disabled for a pure cache.<\/li><li><b>Two sites on one instance:<\/b> always a distinct prefix per installation, or one site flushes the other.<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">On a 1 GB instance, cap <code>maxmemory<\/code> near 128 MB and check available memory right after enabling the drop-in. On 2 GB and above, 256-384 MB is a reasonable ceiling that still leaves the database its own working set. Whatever number you pick, keep an alert on <code>used_memory<\/code> above 80% of the limit &#8211; eviction under a traffic spike is the failure mode that turns a speedup into a slowdown.<\/p>\n\n\n<p>Objects cached in RAM are the cheapest performance win on any WordPress install &#8211; provided the instance has room for them. If your measurements show Redis being evicted during traffic peaks, the memory tier is the constraint; the <a href=\"https:\/\/virtualserversvps.com\/\">VPS plans with full root access<\/a> page lists RAM and vCPU options so you can size the cache before it starts thrashing.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Page caching hides the problem; object caching fixes it. On a 2 vCPU \/ 2 GB instance, moving WordPress persistent object cache from MySQL to Redis cut median database query&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":1,"footnotes":""},"categories":[3],"tags":[],"class_list":["post-1100","post","type-post","status-publish","format-standard","hentry","category-performance-optimization"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.1 (Yoast SEO v26.1) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Redis Object Caching for WordPress on a VPS: Install, Tune, and Measure the Speedup - Virtual Servers VPS Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/virtualserversvps.com\/blog\/redis-object-cache-wordpress-vps-setup\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Redis Object Caching for WordPress on a VPS: Install, Tune, and Measure the Speedup\" \/>\n<meta property=\"og:description\" content=\"Redis Object Caching for WordPress on a VPS: Install, Tune, and Measure the Speedup\" \/>\n<meta property=\"og:url\" content=\"https:\/\/virtualserversvps.com\/blog\/redis-object-cache-wordpress-vps-setup\/\" \/>\n<meta property=\"og:site_name\" content=\"Virtual Servers VPS Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-11T23:10:54+00:00\" \/>\n<meta name=\"author\" content=\"Virtual-Servers-Vps-Editor\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Virtual-Servers-Vps-Editor\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/redis-object-cache-wordpress-vps-setup\/\",\"url\":\"https:\/\/virtualserversvps.com\/blog\/redis-object-cache-wordpress-vps-setup\/\",\"name\":\"Redis Object Caching for WordPress on a VPS: Install, Tune, and Measure the Speedup - Virtual Servers VPS Blog\",\"isPartOf\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#website\"},\"datePublished\":\"2026-09-11T23:10:54+00:00\",\"author\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0\"},\"breadcrumb\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/redis-object-cache-wordpress-vps-setup\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/virtualserversvps.com\/blog\/redis-object-cache-wordpress-vps-setup\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/redis-object-cache-wordpress-vps-setup\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/virtualserversvps.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Redis Object Caching for WordPress on a VPS: Install, Tune, and Measure the Speedup\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#website\",\"url\":\"https:\/\/virtualserversvps.com\/blog\/\",\"name\":\"Virtual Servers VPS Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/virtualserversvps.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0\",\"name\":\"Virtual-Servers-Vps-Editor\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g\",\"caption\":\"Virtual-Servers-Vps-Editor\"},\"sameAs\":[\"https:\/\/virtualserversvps.com\/blog\"],\"url\":\"https:\/\/virtualserversvps.com\/blog\/author\/virtualserversvps\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Redis Object Caching for WordPress on a VPS: Install, Tune, and Measure the Speedup - Virtual Servers VPS Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/virtualserversvps.com\/blog\/redis-object-cache-wordpress-vps-setup\/","og_locale":"en_US","og_type":"article","og_title":"Redis Object Caching for WordPress on a VPS: Install, Tune, and Measure the Speedup","og_description":"Redis Object Caching for WordPress on a VPS: Install, Tune, and Measure the Speedup","og_url":"https:\/\/virtualserversvps.com\/blog\/redis-object-cache-wordpress-vps-setup\/","og_site_name":"Virtual Servers VPS Blog","article_published_time":"2026-09-11T23:10:54+00:00","author":"Virtual-Servers-Vps-Editor","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Virtual-Servers-Vps-Editor","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/virtualserversvps.com\/blog\/redis-object-cache-wordpress-vps-setup\/","url":"https:\/\/virtualserversvps.com\/blog\/redis-object-cache-wordpress-vps-setup\/","name":"Redis Object Caching for WordPress on a VPS: Install, Tune, and Measure the Speedup - Virtual Servers VPS Blog","isPartOf":{"@id":"https:\/\/virtualserversvps.com\/blog\/#website"},"datePublished":"2026-09-11T23:10:54+00:00","author":{"@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0"},"breadcrumb":{"@id":"https:\/\/virtualserversvps.com\/blog\/redis-object-cache-wordpress-vps-setup\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/virtualserversvps.com\/blog\/redis-object-cache-wordpress-vps-setup\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/virtualserversvps.com\/blog\/redis-object-cache-wordpress-vps-setup\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/virtualserversvps.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Redis Object Caching for WordPress on a VPS: Install, Tune, and Measure the Speedup"}]},{"@type":"WebSite","@id":"https:\/\/virtualserversvps.com\/blog\/#website","url":"https:\/\/virtualserversvps.com\/blog\/","name":"Virtual Servers VPS Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/virtualserversvps.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0","name":"Virtual-Servers-Vps-Editor","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g","caption":"Virtual-Servers-Vps-Editor"},"sameAs":["https:\/\/virtualserversvps.com\/blog"],"url":"https:\/\/virtualserversvps.com\/blog\/author\/virtualserversvps\/"}]}},"_links":{"self":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/1100","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/comments?post=1100"}],"version-history":[{"count":3,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/1100\/revisions"}],"predecessor-version":[{"id":1107,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/1100\/revisions\/1107"}],"wp:attachment":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/media?parent=1100"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/categories?post=1100"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/tags?post=1100"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}