{"id":3463,"date":"2025-12-27T13:12:17","date_gmt":"2025-12-27T10:12:17","guid":{"rendered":"https:\/\/www.dchost.com\/blog\/wordpress-object-cache-with-redis-or-memcached-step-by-step-for-shared-hosting-and-vps\/"},"modified":"2025-12-27T13:12:17","modified_gmt":"2025-12-27T10:12:17","slug":"wordpress-object-cache-with-redis-or-memcached-step-by-step-for-shared-hosting-and-vps","status":"publish","type":"post","link":"https:\/\/www.dchost.com\/blog\/en\/wordpress-object-cache-with-redis-or-memcached-step-by-step-for-shared-hosting-and-vps\/","title":{"rendered":"WordPress Object Cache with Redis or Memcached: Step\u2011by\u2011Step for Shared Hosting and VPS"},"content":{"rendered":"<div class=\"dchost-blog-content-wrapper\"><p>If you manage a busy WordPress site, you already know that page caching alone is not always enough. Dynamic queries, WooCommerce carts, mega\u2011menus pulling dozens of options, and bloated <code>wp_options<\/code> tables can still keep your database under constant pressure. That is exactly where a <strong>persistent object cache<\/strong> with Redis or Memcached changes the game. Instead of asking MySQL the same questions on every request, WordPress can store query results in RAM and reuse them in milliseconds. The result is lower TTFB, fewer slow queries, and much better resilience under traffic spikes.<\/p>\n<p>In this guide, we will walk through <strong>step\u2011by\u2011step setups for both shared hosting and <a href=\"https:\/\/www.dchost.com\/vps\">VPS<\/a><\/strong>. We will explain what object cache really does, how Redis and Memcached differ, how to enable them safely on typical cPanel\/DirectAdmin hosting, and how to install and tune them on your own VPS. All examples are based on real\u2011world configurations we use at dchost.com when helping customers speed up WordPress and WooCommerce.<\/p>\n<div id=\"toc_container\" class=\"toc_transparent no_bullets\"><p class=\"toc_title\">\u0130&ccedil;indekiler<\/p><ul class=\"toc_list\"><li><a href=\"#What_WordPress_Object_Cache_Actually_Does_And_Why_Page_Cache_Is_Not_Enough\"><span class=\"toc_number toc_depth_1\">1<\/span> What WordPress Object Cache Actually Does (And Why Page Cache Is Not Enough)<\/a><\/li><li><a href=\"#Redis_vs_Memcached_for_WordPress_Which_One_Should_You_Use\"><span class=\"toc_number toc_depth_1\">2<\/span> Redis vs Memcached for WordPress: Which One Should You Use?<\/a><ul><li><a href=\"#Redis_in_a_nutshell\"><span class=\"toc_number toc_depth_2\">2.1<\/span> Redis in a nutshell<\/a><\/li><li><a href=\"#Memcached_in_a_nutshell\"><span class=\"toc_number toc_depth_2\">2.2<\/span> Memcached in a nutshell<\/a><\/li><\/ul><\/li><li><a href=\"#Planning_Shared_Hosting_vs_VPS_for_Object_Cache\"><span class=\"toc_number toc_depth_1\">3<\/span> Planning: Shared Hosting vs VPS for Object Cache<\/a><ul><li><a href=\"#On_shared_hosting\"><span class=\"toc_number toc_depth_2\">3.1<\/span> On shared hosting<\/a><\/li><li><a href=\"#On_a_VPS\"><span class=\"toc_number toc_depth_2\">3.2<\/span> On a VPS<\/a><\/li><\/ul><\/li><li><a href=\"#StepbyStep_Enable_Object_Cache_on_Shared_Hosting\"><span class=\"toc_number toc_depth_1\">4<\/span> Step\u2011by\u2011Step: Enable Object Cache on Shared Hosting<\/a><ul><li><a href=\"#1_Check_if_Redis_or_Memcached_is_Available\"><span class=\"toc_number toc_depth_2\">4.1<\/span> 1. Check if Redis or Memcached is Available<\/a><\/li><li><a href=\"#2_Choose_a_WordPress_Object_Cache_Plugin\"><span class=\"toc_number toc_depth_2\">4.2<\/span> 2. Choose a WordPress Object Cache Plugin<\/a><\/li><li><a href=\"#3_Configure_Redis_Object_Cache_on_Shared_Hosting\"><span class=\"toc_number toc_depth_2\">4.3<\/span> 3. Configure Redis Object Cache on Shared Hosting<\/a><\/li><li><a href=\"#4_Configure_Memcached_Object_Cache_on_Shared_Hosting\"><span class=\"toc_number toc_depth_2\">4.4<\/span> 4. Configure Memcached Object Cache on Shared Hosting<\/a><\/li><li><a href=\"#5_Verify_That_Object_Cache_Is_Working\"><span class=\"toc_number toc_depth_2\">4.5<\/span> 5. Verify That Object Cache Is Working<\/a><\/li><\/ul><\/li><li><a href=\"#StepbyStep_Install_and_Configure_RedisMemcached_on_a_VPS\"><span class=\"toc_number toc_depth_1\">5<\/span> Step\u2011by\u2011Step: Install and Configure Redis\/Memcached on a VPS<\/a><ul><li><a href=\"#1_Prerequisites\"><span class=\"toc_number toc_depth_2\">5.1<\/span> 1. Prerequisites<\/a><\/li><li><a href=\"#2_Install_Redis_on_a_VPS\"><span class=\"toc_number toc_depth_2\">5.2<\/span> 2. Install Redis on a VPS<\/a><\/li><li><a href=\"#3_Install_Memcached_on_a_VPS\"><span class=\"toc_number toc_depth_2\">5.3<\/span> 3. Install Memcached on a VPS<\/a><\/li><li><a href=\"#4_Connect_WordPress_to_Redis_on_a_VPS\"><span class=\"toc_number toc_depth_2\">5.4<\/span> 4. Connect WordPress to Redis on a VPS<\/a><\/li><li><a href=\"#5_Connect_WordPress_to_Memcached_on_a_VPS\"><span class=\"toc_number toc_depth_2\">5.5<\/span> 5. Connect WordPress to Memcached on a VPS<\/a><\/li><\/ul><\/li><li><a href=\"#Testing_Monitoring_and_Troubleshooting_Object_Cache\"><span class=\"toc_number toc_depth_1\">6<\/span> Testing, Monitoring and Troubleshooting Object Cache<\/a><ul><li><a href=\"#1_Watch_Cache_Hit_Ratios\"><span class=\"toc_number toc_depth_2\">6.1<\/span> 1. Watch Cache Hit Ratios<\/a><\/li><li><a href=\"#2_Compare_Database_Load_Before_and_After\"><span class=\"toc_number toc_depth_2\">6.2<\/span> 2. Compare Database Load Before and After<\/a><\/li><li><a href=\"#3_Common_Problems_and_Fixes\"><span class=\"toc_number toc_depth_2\">6.3<\/span> 3. Common Problems and Fixes<\/a><\/li><\/ul><\/li><li><a href=\"#Best_Practices_for_Stable_Fast_WordPress_Object_Caching\"><span class=\"toc_number toc_depth_1\">7<\/span> Best Practices for Stable, Fast WordPress Object Caching<\/a><ul><li><a href=\"#1_Keep_RedisMemcached_Local_or_on_a_Private_Network\"><span class=\"toc_number toc_depth_2\">7.1<\/span> 1. Keep Redis\/Memcached Local or on a Private Network<\/a><\/li><li><a href=\"#2_Choose_Sensible_TTLs_and_Eviction_Policies\"><span class=\"toc_number toc_depth_2\">7.2<\/span> 2. Choose Sensible TTLs and Eviction Policies<\/a><\/li><li><a href=\"#3_Pair_Object_Cache_with_Page_Cache_and_PHPMySQL_Tuning\"><span class=\"toc_number toc_depth_2\">7.3<\/span> 3. Pair Object Cache with Page Cache and PHP\/MySQL Tuning<\/a><\/li><li><a href=\"#4_Watch_Disk_and_RAM_on_VPS_Plans\"><span class=\"toc_number toc_depth_2\">7.4<\/span> 4. Watch Disk and RAM on VPS Plans<\/a><\/li><\/ul><\/li><li><a href=\"#When_to_Move_Beyond_a_Single_Server_Object_Cache\"><span class=\"toc_number toc_depth_1\">8<\/span> When to Move Beyond a Single Server Object Cache<\/a><\/li><li><a href=\"#Summary_and_How_We_Approach_This_at_dchostcom\"><span class=\"toc_number toc_depth_1\">9<\/span> Summary and How We Approach This at dchost.com<\/a><\/li><\/ul><\/div>\n<h2><span id=\"What_WordPress_Object_Cache_Actually_Does_And_Why_Page_Cache_Is_Not_Enough\">What WordPress Object Cache Actually Does (And Why Page Cache Is Not Enough)<\/span><\/h2>\n<p>WordPress already has an internal object cache layer, but by default it is <strong>in\u2011memory per PHP process only<\/strong>. Each request starts with an empty cache and throws it away at the end. A <strong>persistent object cache<\/strong> stores those objects in an external service such as Redis or Memcached, so that other PHP processes and future requests can reuse them.<\/p>\n<p>What typically ends up in object cache?<\/p>\n<ul>\n<li>Results of expensive database queries (posts, terms, user meta, options)<\/li>\n<li>Transients and options from the <code>wp_options<\/code> table<\/li>\n<li>Complex query results used by big menus, product filters, related posts<\/li>\n<li>Fragments that page cache plugins cannot safely cache (e.g. user\u2011specific data)<\/li>\n<\/ul>\n<p>If your <code>wp_options<\/code> table is already bloated or full of autoloaded rows, a persistent cache will help hide the symptoms, but you should still clean it. For that part, we highly recommend our detailed guide on <a href=\"https:\/\/www.dchost.com\/blog\/en\/wordpress-veritabani-optimizasyonu-wp_options-ve-autoload-sismesini-temizleme-rehberi\/\">WordPress database optimization, focusing on <code>wp_options<\/code> and autoload bloat<\/a>.<\/p>\n<p>Object cache works <strong>together<\/strong> with page caching, PHP\u2011FPM tuning and OPcache. If you have not yet reviewed your PHP and server settings, our article <a href=\"https:\/\/www.dchost.com\/blog\/en\/wordpress-icin-sunucu-tarafi-optimizasyon-php-fpm-opcache-redis-ve-mysql-ile-neyi-ne-zaman-nasil-ayarlamalisin\/\">The server\u2011side secrets that make WordPress fly<\/a> is a good companion read.<\/p>\n<h2><span id=\"Redis_vs_Memcached_for_WordPress_Which_One_Should_You_Use\">Redis vs Memcached for WordPress: Which One Should You Use?<\/span><\/h2>\n<p>Both Redis and Memcached are in\u2011memory key\u2013value stores often used as object cache backends. From a WordPress perspective, they solve the same problem, but with different capabilities.<\/p>\n<h3><span id=\"Redis_in_a_nutshell\">Redis in a nutshell<\/span><\/h3>\n<ul>\n<li>Supports complex data types (lists, hashes, sets, sorted sets)<\/li>\n<li>Has built\u2011in <strong>persistence<\/strong> (RDB snapshots, AOF) if you enable it<\/li>\n<li>Provides more introspection: keys, memory usage, hit ratio, latency<\/li>\n<li>Great ecosystem for high availability and clustering when you outgrow a single VPS<\/li>\n<\/ul>\n<h3><span id=\"Memcached_in_a_nutshell\">Memcached in a nutshell<\/span><\/h3>\n<ul>\n<li>Extremely simple and very fast for pure key\u2013value lookups<\/li>\n<li>No built\u2011in persistence: data lives only in RAM<\/li>\n<li>Very lightweight; commonly available on shared hosting<\/li>\n<li>Scaling is usually done via client\u2011side sharding across multiple nodes<\/li>\n<\/ul>\n<p>For most modern WordPress and WooCommerce sites we assist at dchost.com, we lean slightly towards <strong>Redis<\/strong> because of its tooling, observability and features like persistence and key introspection. But Memcached is still a good choice, especially on shared hosting where it may already be available and pre\u2011configured.<\/p>\n<p>If you want a deeper comparison including TTL strategies and eviction policies, we have a separate in\u2011depth article: <a href=\"https:\/\/www.dchost.com\/blog\/en\/wordpress-ve-woocommerce-icin-redis-mi-memcached-mi-kalici-nesne-onbellegi-ttl-ve-eviction-ayarlarini-ne-zaman-nasil-yaparsin\/\">Redis vs Memcached for WordPress\/WooCommerce with practical TTL and eviction tuning<\/a>.<\/p>\n<h2><span id=\"Planning_Shared_Hosting_vs_VPS_for_Object_Cache\">Planning: Shared Hosting vs VPS for Object Cache<\/span><\/h2>\n<p>The way you enable Redis or Memcached depends heavily on whether you are on <strong>shared hosting<\/strong> or you control a <strong>VPS<\/strong> (or <a href=\"https:\/\/www.dchost.com\/dedicated-server\">dedicated server<\/a>).<\/p>\n<h3><span id=\"On_shared_hosting\">On shared hosting<\/span><\/h3>\n<ul>\n<li>You typically do <strong>not<\/strong> have root SSH access.<\/li>\n<li>Redis or Memcached may already be running on the server, exposed via a local socket or TCP port.<\/li>\n<li>The main job is to install the right WordPress plugin and point it to the existing service.<\/li>\n<li>Tuning options (memory, eviction policy) are usually limited or fixed by the provider.<\/li>\n<\/ul>\n<p>At dchost.com, we commonly see customers combine persistent object cache with LiteSpeed\u2011based page caching. If you are on LiteSpeed web server, our guide <a href=\"https:\/\/www.dchost.com\/blog\/en\/litespeed-cache-eklentisi-ile-wordpress-hizlandirma-paylasimli-hosting-icin-detayli-ayar-rehberi\/\">speeding up WordPress with LiteSpeed Cache on shared hosting<\/a> fits neatly together with the object cache setup you will read below.<\/p>\n<h3><span id=\"On_a_VPS\">On a VPS<\/span><\/h3>\n<ul>\n<li>You (or your sysadmin) have root access and are responsible for installation and security.<\/li>\n<li>You can decide how much RAM Redis\/Memcached gets and which eviction policy is used.<\/li>\n<li>You can bind services to <code>127.0.0.1<\/code> only (recommended) or run them over a private network.<\/li>\n<li>You can later move Redis\/Memcached to a separate VPS if the site grows.<\/li>\n<\/ul>\n<p>If you are currently on shared hosting and frequently hit CPU or IO limits even after enabling caching, it might be time to upgrade. We explain the process in detail in <a href=\"https:\/\/www.dchost.com\/blog\/en\/paylasimli-hostingden-vpse-sorunsuz-gecis-rehberi\/\">our guide to moving from shared hosting to a VPS without downtime<\/a> and in <a href=\"https:\/\/www.dchost.com\/blog\/en\/woocommerce-laravel-ve-node-jsde-dogru-vps-kaynaklarini-nasil-secersin-cpu-ram-nvme-ve-bant-genisligi-rehberi\/\">how we choose VPS specs for WooCommerce, Laravel and Node.js without overpaying<\/a>.<\/p>\n<h2><span id=\"StepbyStep_Enable_Object_Cache_on_Shared_Hosting\">Step\u2011by\u2011Step: Enable Object Cache on Shared Hosting<\/span><\/h2>\n<p>We will assume you use a typical cPanel or DirectAdmin shared hosting account, with PHP already working and WordPress installed.<\/p>\n<h3><span id=\"1_Check_if_Redis_or_Memcached_is_Available\">1. Check if Redis or Memcached is Available<\/span><\/h3>\n<p>First, confirm what your hosting account supports:<\/p>\n<ul>\n<li>Log in to your hosting control panel.<\/li>\n<li>Look for sections like <strong>&#8220;Select PHP Version&#8221;<\/strong>, <strong>&#8220;PHP Extensions&#8221;<\/strong>, or <strong>&#8220;PHP PEAR\/PECL&#8221;<\/strong>.<\/li>\n<li>Check if <code>redis<\/code> and\/or <code>memcached<\/code> extensions are listed and enabled.<\/li>\n<\/ul>\n<p>You can also create a small PHP info file to confirm:<\/p>\n<pre class=\"language-php line-numbers\"><code class=\"language-php\">&lt;?php\nphpinfo();\n<\/code><\/pre>\n<p>Upload it as <code>phpinfo.php<\/code> to your site root, open it in a browser, and search for <code>redis<\/code> or <code>memcached<\/code>. Once you confirm one of them is present, delete this file for security.<\/p>\n<p>Some providers document the connection details (host, port, socket path) in their knowledge base or panel. At dchost.com, for example, we clearly state connection strings for supported cache services so you can plug them into your plugin quickly.<\/p>\n<h3><span id=\"2_Choose_a_WordPress_Object_Cache_Plugin\">2. Choose a WordPress Object Cache Plugin<\/span><\/h3>\n<p>You need a plugin that knows how to talk to Redis or Memcached and integrate with WordPress\u2019 object cache API. Popular choices include:<\/p>\n<ul>\n<li><strong>Redis Object Cache<\/strong> plugin (simple, focused, widely used)<\/li>\n<li><strong>W3 Total Cache<\/strong> (full suite with page, object and database cache)<\/li>\n<li><strong>Litespeed Cache<\/strong> (if you are on LiteSpeed, it supports Redis\/Memcached as backend)<\/li>\n<\/ul>\n<p>On shared hosting we usually recommend starting with <strong>Redis Object Cache<\/strong> or your existing performance plugin\u2019s object cache module, to avoid overlapping features.<\/p>\n<h3><span id=\"3_Configure_Redis_Object_Cache_on_Shared_Hosting\">3. Configure Redis Object Cache on Shared Hosting<\/span><\/h3>\n<ol>\n<li>In WordPress admin, go to <strong>Plugins \u2192 Add New<\/strong> and search for \u201cRedis Object Cache\u201d.<\/li>\n<li>Install and activate the plugin.<\/li>\n<li>Go to <strong>Settings \u2192 Redis<\/strong> (or <strong>Tools \u2192 Redis<\/strong>, depending on version).<\/li>\n<li>Click <strong>Enable Object Cache<\/strong>.<\/li>\n<\/ol>\n<p>If your hosting provider uses default settings (Redis on <code>127.0.0.1:6379<\/code> or a local socket), the plugin will often detect it automatically. If not, switch to advanced settings and fill in:<\/p>\n<ul>\n<li><strong>Host:<\/strong> the Redis hostname or IP (often <code>127.0.0.1<\/code> or <code>localhost<\/code>)<\/li>\n<li><strong>Port:<\/strong> commonly <code>6379<\/code><\/li>\n<li><strong>Database:<\/strong> an integer like <code>0<\/code> or <code>1<\/code> (your host might assign each account its own DB index)<\/li>\n<li><strong>Prefix:<\/strong> useful if you run multiple WordPress installs on the same Redis (e.g. <code>myshop_<\/code>)<\/li>\n<\/ul>\n<p>After saving, the plugin will typically create a <code>object-cache.php<\/code> drop\u2011in in <code>wp-content<\/code>. This file overrides WordPress\u2019 internal object cache and routes all calls to Redis.<\/p>\n<h3><span id=\"4_Configure_Memcached_Object_Cache_on_Shared_Hosting\">4. Configure Memcached Object Cache on Shared Hosting<\/span><\/h3>\n<p>If Memcached is available but Redis is not, the process is similar:<\/p>\n<ul>\n<li>Install a plugin that supports Memcached as an object cache backend (for example, W3 Total Cache).<\/li>\n<li>In W3 Total Cache, go to <strong>Performance \u2192 General Settings<\/strong>.<\/li>\n<li>Under <strong>Object Cache<\/strong>, choose <strong>Memcached<\/strong> as the method and save.<\/li>\n<li>Under <strong>Performance \u2192 Object Cache<\/strong>, configure the Memcached servers (e.g. <code>127.0.0.1:11211<\/code>).<\/li>\n<\/ul>\n<p>If your host runs a shared Memcached instance, they may provide a specific host and port. Always prefer <code>127.0.0.1<\/code> or a Unix socket when possible \u2013 it\u2019s slightly faster and does not cross the network stack.<\/p>\n<h3><span id=\"5_Verify_That_Object_Cache_Is_Working\">5. Verify That Object Cache Is Working<\/span><\/h3>\n<p>After enabling Redis or Memcached, you should verify that it is actually being used:<\/p>\n<ul>\n<li>Most plugins show <strong>status<\/strong>, <strong>hits<\/strong> and <strong>misses<\/strong> on their settings page.<\/li>\n<li>You can install the <strong>Query Monitor<\/strong> plugin to see reduced database query counts on cached pages.<\/li>\n<li>Test under load with tools like Loader.io, k6 or your preferred alternative; TTFB should be more stable.<\/li>\n<\/ul>\n<p>If you see errors like \u201cCould not connect to Redis\u201d or \u201cMemcached extension not loaded\u201d, double\u2011check that the PHP extension is enabled and that your credentials (host, port, socket) are correct. If issues persist, your hosting support team (for dchost.com customers, that\u2019s us) can confirm server\u2011side connectivity.<\/p>\n<h2><span id=\"StepbyStep_Install_and_Configure_RedisMemcached_on_a_VPS\">Step\u2011by\u2011Step: Install and Configure Redis\/Memcached on a VPS<\/span><\/h2>\n<p>On a VPS you control both the cache service and the WordPress site. This gives you more power \u2013 and more responsibility. The examples below assume a typical Debian\/Ubuntu\u2011based server with Nginx or Apache, PHP\u2011FPM and MariaDB\/MySQL.<\/p>\n<h3><span id=\"1_Prerequisites\">1. Prerequisites<\/span><\/h3>\n<ul>\n<li>Root SSH access to your VPS.<\/li>\n<li>WordPress installed and working over PHP\u2011FPM.<\/li>\n<li>Basic familiarity with editing config files in <code>nano<\/code> or <code>vim<\/code>.<\/li>\n<\/ul>\n<p>If you are setting up a fresh VPS, our articles on <a href=\"https:\/\/www.dchost.com\/blog\/en\/yeni-vpste-ilk-24-saat-guncelleme-guvenlik-duvari-ve-kullanici-hesaplari\/\">securing a new VPS in the first 24 hours<\/a> and on <a href=\"https:\/\/www.dchost.com\/blog\/en\/php-ayarlarini-dogru-yapmak-memory_limit-max_execution_time-ve-upload_max_filesize-kac-olmali\/\">choosing the right PHP limits<\/a> are worth skimming before you go live.<\/p>\n<h3><span id=\"2_Install_Redis_on_a_VPS\">2. Install Redis on a VPS<\/span><\/h3>\n<p>On Debian\/Ubuntu:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">sudo apt update\nsudo apt install redis-server php-redis -y\n<\/code><\/pre>\n<p>Then harden and tune Redis. Open <code>\/etc\/redis\/redis.conf<\/code>:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">sudo nano \/etc\/redis\/redis.conf\n<\/code><\/pre>\n<p>Recommended baseline settings for a single VPS:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">bind 127.0.0.1\nprotected-mode yes\nport 6379\n\n# Limit memory usage (example: 512MB)\nmaxmemory 512mb\nmaxmemory-policy allkeys-lru\n<\/code><\/pre>\n<ul>\n<li><strong>bind 127.0.0.1<\/strong> ensures Redis is not exposed to the public internet.<\/li>\n<li><strong>maxmemory<\/strong> prevents Redis from consuming all your RAM.<\/li>\n<li><strong>maxmemory-policy allkeys-lru<\/strong> is generally safe for WordPress: least\u2011recently\u2011used eviction of any key.<\/li>\n<\/ul>\n<p>Restart Redis:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">sudo systemctl restart redis-server\nsudo systemctl enable redis-server\n<\/code><\/pre>\n<p>Test from the shell:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">redis-cli ping\n# Response should be: PONG\n<\/code><\/pre>\n<h3><span id=\"3_Install_Memcached_on_a_VPS\">3. Install Memcached on a VPS<\/span><\/h3>\n<p>If you prefer Memcached or want both options available:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">sudo apt update\nsudo apt install memcached php-memcached -y\n<\/code><\/pre>\n<p>Edit <code>\/etc\/memcached.conf<\/code>:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">sudo nano \/etc\/memcached.conf\n<\/code><\/pre>\n<p>Key parameters:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\"># Memory in MB\ndefault: -m 64\n\n# Listen on localhost only\n-l 127.0.0.1\n<\/code><\/pre>\n<p>Adjust <code>-m<\/code> to a reasonable value, e.g. <code>-m 256<\/code> or <code>-m 512<\/code> depending on your VPS RAM. Then restart:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">sudo systemctl restart memcached\nsudo systemctl enable memcached\n<\/code><\/pre>\n<h3><span id=\"4_Connect_WordPress_to_Redis_on_a_VPS\">4. Connect WordPress to Redis on a VPS<\/span><\/h3>\n<p>Back to WordPress:<\/p>\n<ol>\n<li>Install and activate the <strong>Redis Object Cache<\/strong> plugin.<\/li>\n<li>In the plugin settings, set <strong>Host<\/strong> to <code>127.0.0.1<\/code> and <strong>Port<\/strong> to <code>6379<\/code>.<\/li>\n<li>Click <strong>Enable Object Cache<\/strong>.<\/li>\n<\/ol>\n<p>For advanced setups, you can configure Redis in <code>wp-config.php<\/code> before the <code>\/* That's all, stop editing! *\/<\/code> line:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">define( 'WP_REDIS_HOST', '127.0.0.1' );\ndefine( 'WP_REDIS_PORT', 6379 );\n\/\/ Optional: use a non-default database if you share Redis\n\/\/ define( 'WP_REDIS_DATABASE', 1 );\n\/\/ Optional: prefix if multiple installs share one Redis\n\/\/ define( 'WP_CACHE_KEY_SALT', 'myshop_example_com_' );\n<\/code><\/pre>\n<p>Save, then go to the plugin page and confirm that it detects Redis and reports an active connection with a non\u2011zero hit ratio after some traffic.<\/p>\n<h3><span id=\"5_Connect_WordPress_to_Memcached_on_a_VPS\">5. Connect WordPress to Memcached on a VPS<\/span><\/h3>\n<p>With Memcached and <code>php-memcached<\/code> installed, you can use W3 Total Cache, LiteSpeed Cache or another plugin that supports it:<\/p>\n<ul>\n<li>Install your chosen plugin.<\/li>\n<li>Enable <strong>Object Cache<\/strong> and pick <strong>Memcached<\/strong> as the method.<\/li>\n<li>Set the server as <code>127.0.0.1:11211<\/code>.<\/li>\n<\/ul>\n<p>Some object cache drop\u2011ins specifically designed for Memcached may require placing a custom <code>object-cache.php<\/code> file into <code>wp-content<\/code>. Always follow the plugin\u2019s documentation carefully; don\u2019t leave multiple incompatible drop\u2011ins active at the same time.<\/p>\n<h2><span id=\"Testing_Monitoring_and_Troubleshooting_Object_Cache\">Testing, Monitoring and Troubleshooting Object Cache<\/span><\/h2>\n<p>Once Redis or Memcached is connected, the real question is: <strong>is it helping?<\/strong> Here are practical checks we use day\u2011to\u2011day.<\/p>\n<h3><span id=\"1_Watch_Cache_Hit_Ratios\">1. Watch Cache Hit Ratios<\/span><\/h3>\n<p>Most Redis\/Memcached plugins display hit and miss counts. After some normal traffic, you should see the hit ratio trend upward. If it remains near zero, something is wrong (or your cache is constantly being flushed).<\/p>\n<p>For Redis, from the server console:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">redis-cli info stats | egrep 'keyspace_hits|keyspace_misses'\n<\/code><\/pre>\n<p>For Memcached, you can use:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">echo stats | nc 127.0.0.1 11211 | egrep 'get_hits|get_misses'\n<\/code><\/pre>\n<h3><span id=\"2_Compare_Database_Load_Before_and_After\">2. Compare Database Load Before and After<\/span><\/h3>\n<p>Use Query Monitor or your database\u2019s slow query log to compare:<\/p>\n<ul>\n<li>Average number of queries on cached pages<\/li>\n<li>Number of slow queries (&gt; 1s) under similar traffic<\/li>\n<\/ul>\n<p>Combined with server\u2011side tuning (PHP\u2011FPM and MySQL\/InnoDB), object cache should reduce both query counts and tail latency. Our article on <a href=\"https:\/\/www.dchost.com\/blog\/en\/wordpress-icin-sunucu-tarafi-optimizasyon-php-fpm-opcache-redis-ve-mysql-ile-neyi-ne-zaman-nasil-ayarlamalisin\/\">server\u2011side optimization for WordPress<\/a> walks through a full tuning checklist that pairs nicely with object caching.<\/p>\n<h3><span id=\"3_Common_Problems_and_Fixes\">3. Common Problems and Fixes<\/span><\/h3>\n<ul>\n<li><strong>&#8220;Error establishing Redis connection&#8221;<\/strong>: check that Redis is running and reachable from the PHP user. On a VPS, confirm <code>systemctl status redis-server<\/code> and that <code>bind<\/code> in <code>redis.conf<\/code> permits localhost.<\/li>\n<li><strong>High memory usage<\/strong>: if Redis or Memcached starts evicting crucial keys too aggressively, raise <code>maxmemory<\/code> (Redis) or <code>-m<\/code> (Memcached) or lower TTLs in your plugin.<\/li>\n<li><strong>Stale or wrong data<\/strong>: relatively rare with object cache, but can happen with aggressive transients. Clearing the object cache after big migrations or plugin changes is safe and often solves the issue.<\/li>\n<li><strong>Conflicts between caching plugins<\/strong>: avoid enabling multiple object cache solutions at once. One <code>object-cache.php<\/code> drop\u2011in at a time.<\/li>\n<\/ul>\n<h2><span id=\"Best_Practices_for_Stable_Fast_WordPress_Object_Caching\">Best Practices for Stable, Fast WordPress Object Caching<\/span><\/h2>\n<p>A few patterns make the difference between \u201cit works sometimes\u201d and \u201cit just runs\u201d in production.<\/p>\n<h3><span id=\"1_Keep_RedisMemcached_Local_or_on_a_Private_Network\">1. Keep Redis\/Memcached Local or on a Private Network<\/span><\/h3>\n<p>For latency\u2011sensitive cache traffic:<\/p>\n<ul>\n<li>Run Redis\/Memcached on the same VPS as PHP, or on a dedicated cache VPS within the same data center region.<\/li>\n<li>Avoid exposing them on public IPs. Use <code>bind 127.0.0.1<\/code> or a private VLAN.<\/li>\n<li>Use firewall rules (UFW, nftables, security groups) to restrict access further.<\/li>\n<\/ul>\n<p>We go deeper into firewall best practices in our VPS security and nftables guides, but the core idea is simple: <strong>never<\/strong> leave Redis or Memcached open to the world.<\/p>\n<h3><span id=\"2_Choose_Sensible_TTLs_and_Eviction_Policies\">2. Choose Sensible TTLs and Eviction Policies<\/span><\/h3>\n<p>Object cache is most effective when it avoids excessive churn:<\/p>\n<ul>\n<li>Use reasonable default TTLs (e.g. minutes to hours) for most objects.<\/li>\n<li>Avoid setting everything to &#8220;no expiration&#8221; if your memory budget is small.<\/li>\n<li>For Redis, <code>allkeys-lru<\/code> is usually a good starting policy; for Memcached, rely on its default LRU behavior.<\/li>\n<\/ul>\n<p>If you want concrete TTL examples tailored to WooCommerce, search filters and heavy menus, our dedicated article on <a href=\"https:\/\/www.dchost.com\/blog\/en\/wordpress-ve-woocommerce-icin-redis-mi-memcached-mi-kalici-nesne-onbellegi-ttl-ve-eviction-ayarlarini-ne-zaman-nasil-yaparsin\/\">Redis vs Memcached TTL and eviction tuning for WordPress\/WooCommerce<\/a> covers several production scenarios.<\/p>\n<h3><span id=\"3_Pair_Object_Cache_with_Page_Cache_and_PHPMySQL_Tuning\">3. Pair Object Cache with Page Cache and PHP\/MySQL Tuning<\/span><\/h3>\n<p>Object cache is not a silver bullet. For best results, combine:<\/p>\n<ul>\n<li><strong>Page cache<\/strong>: via LiteSpeed Cache, Nginx microcaching, or another full\u2011page cache layer<\/li>\n<li><strong>OPcache<\/strong>: so PHP does not recompile scripts on every request<\/li>\n<li><strong>PHP\u2011FPM tuning<\/strong>: right number of workers for your CPU\/RAM<\/li>\n<li><strong>MySQL\/InnoDB tuning<\/strong>: buffer pool size, slow query analysis, and proper indexes<\/li>\n<\/ul>\n<p>We discuss MySQL\/InnoDB tuning for WooCommerce in depth in our article on <a href=\"https:\/\/www.dchost.com\/blog\/en\/woocommerce-icin-mysql-innodb-tuning-kontrol-listesi-buffer-pool-indeksleme-ve-slow-query-analizi-nasil-akillica-yapilir\/\">the WooCommerce MySQL\/InnoDB tuning checklist<\/a>, and page caching strategies in <a href=\"https:\/\/www.dchost.com\/blog\/en\/wordpresste-tam-sayfa-onbellekleme-nasil-kurulur-nginx-fastcgi-cache-varnish-ve-litespeed-cache-ile-woocommercee-nazikce-dokunmak\/\">our full\u2011page caching guide for WordPress that won\u2019t break WooCommerce<\/a>.<\/p>\n<h3><span id=\"4_Watch_Disk_and_RAM_on_VPS_Plans\">4. Watch Disk and RAM on VPS Plans<\/span><\/h3>\n<p>Redis and Memcached keep data in RAM, so you should:<\/p>\n<ul>\n<li>Leave enough memory for PHP\u2011FPM, MySQL and the OS.<\/li>\n<li>Start conservatively (e.g. 256\u2013512 MB for Redis on smaller VPS instances).<\/li>\n<li>Monitor RAM usage and swap; if you see frequent swapping, either lower cache memory or upgrade your VPS.<\/li>\n<\/ul>\n<p>Using NVMe\u2011based VPS plans helps a lot when cache misses fall back to disk. To understand why, our article <a href=\"https:\/\/www.dchost.com\/blog\/en\/nvme-ssd-sata-ssd-ve-hdd-karsilastirmasi-web-hosting-yedek-ve-arsiv-icin-dogru-disk-secimi\/\">comparing NVMe SSD, SATA SSD and HDD for hosting<\/a> explains the performance difference in real\u2011world terms.<\/p>\n<h2><span id=\"When_to_Move_Beyond_a_Single_Server_Object_Cache\">When to Move Beyond a Single Server Object Cache<\/span><\/h2>\n<p>For many sites, a single VPS with Redis or Memcached is more than enough. But as traffic or complexity grows, you may outgrow this architecture. Signs include:<\/p>\n<ul>\n<li>CPU saturation even though your cache hit ratio is high.<\/li>\n<li>Long MySQL queries because your data model or reporting needs became complex.<\/li>\n<li>Need for high availability or maintenance windows with zero cache loss.<\/li>\n<\/ul>\n<p>At that stage, you may:<\/p>\n<ul>\n<li>Offload Redis to a <strong>dedicated cache VPS<\/strong> within the same data center.<\/li>\n<li>Scale MySQL with replicas or clusters.<\/li>\n<li>Introduce a load balancer and multiple PHP\u2011FPM nodes sharing the same Redis cluster.<\/li>\n<\/ul>\n<p>We have a separate advanced guide focused on <a href=\"https:\/\/www.dchost.com\/blog\/en\/wordpress-nesne-onbelleginde-redisi-ayaga-kaldirmanin-sirri-sentinel-aof-rdb-ve-failover-ne-zaman-devreye-girer\/\">high\u2011availability Redis for WordPress with Sentinel, AOF\/RDB and real failover<\/a>, which is a natural next step when a single Redis instance is no longer enough.<\/p>\n<h2><span id=\"Summary_and_How_We_Approach_This_at_dchostcom\">Summary and How We Approach This at dchost.com<\/span><\/h2>\n<p>Persistent object cache with Redis or Memcached is one of the highest\u2011impact, relatively low\u2011risk optimizations you can make for WordPress and WooCommerce. On shared hosting, it is often as simple as enabling a PHP extension, installing the right plugin and pasting a host\/port. On a VPS, you gain full control over installation, memory, security and eviction policies, which lets you squeeze the most out of your hardware.<\/p>\n<p>In real\u2011world projects we manage at dchost.com, the winning formula usually looks like this:<\/p>\n<ul>\n<li>Clean up <code>wp_options<\/code> and slow queries first.<\/li>\n<li>Enable page cache and OPcache.<\/li>\n<li>Add Redis (or Memcached) as a persistent object cache.<\/li>\n<li>Tune PHP\u2011FPM and MySQL to match your traffic pattern.<\/li>\n<\/ul>\n<p>This layered approach keeps your site fast and predictable, even during campaigns or seasonal peaks. If you are already hosting with us and want to enable Redis or Memcached, our support team can confirm what is available on your plan and help you pick a safe configuration. If you are planning a move to a VPS or dedicated server, we can size your resources (CPU, RAM, NVMe, bandwidth) so that WordPress object cache has enough headroom to really shine.<\/p>\n<p>The next practical step: decide whether you will start on your current shared hosting or on a VPS, pick Redis or Memcached with the considerations above, and follow the relevant step\u2011by\u2011step section. Once your object cache is live, give your site a few days under normal traffic, monitor hit ratios and database load, and then iterate. Small, deliberate tuning moves in caching usually pay back far more than one\u2011off \u201coptimization\u201d plugins, and they give you a predictable performance foundation to grow on.<\/p>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>If you manage a busy WordPress site, you already know that page caching alone is not always enough. Dynamic queries, WooCommerce carts, mega\u2011menus pulling dozens of options, and bloated wp_options tables can still keep your database under constant pressure. That is exactly where a persistent object cache with Redis or Memcached changes the game. Instead [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3464,"comment_status":"","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26],"tags":[],"class_list":["post-3463","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-teknoloji"],"_links":{"self":[{"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/posts\/3463","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/comments?post=3463"}],"version-history":[{"count":0,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/posts\/3463\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/media\/3464"}],"wp:attachment":[{"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/media?parent=3463"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/categories?post=3463"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/tags?post=3463"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}