Redis Object Cache for WordPress and WooCommerce is a server-side caching technique that stores SQL query results, options objects, and transients in RAM. It solves the problem of high latency (TTFB) on dynamic pages where static page caching does not work: in the cart, on the checkout page, and in the user's personal account.

Why static cache doesn't work in WooCommerce and how Redis helps

Why static cache doesn't work in WooCommerce and how Redis helps — VORONOV Solutions

For most WordPress information pages, classic HTML caching (e.g. via Nginx FastCGI Cache, LiteSpeed, or NGINX/WP Rocket plugins) is sufficient. However, for WooCommerce online stores, this approach has significant limitations. According to official WooCommerce recommendations, endpoints such as /cart/, /checkout/ and sessions of authorized buyers are fundamentally not subject to static caching, as they display personalized data.

When a user adds a product to their cart, each click generates dozens of complex SQL queries to the MySQL database (product metadata, balances, discount rules, sessions). Without object caching, the database becomes a «bottleneck», causing server response delays (TTFB > 1–2 seconds), which directly worsens behavioral factors. We wrote more about this in the article about, How website loading speed affects SEO and sales.

In accordance with WordPress documentation WP_Object_Cache, wordpress object caching is designed to intercept repeated database accesses. Redis stores processed PHP objects directly in RAM, returning them in fractions of a millisecond.

Interaction architecture: PHP-FPM, Redis and MySQL

Interaction architecture: PHP-FPM, Redis and MySQL — VORONOV Solutions

The query workflow with Redis connected looks like this:

  1. User request: The browser accesses a dynamic page (for example, a shopping cart).
  2. Checking the cache: PHP script via object coupler (object-cache.php) checks for the presence of the required objects in Redis.
  3. Cache Hit: If data is found in RAM, it is immediately returned to PHP. The query to MySQL is not executed.
  4. Cache Miss: If there is no data, PHP makes a query to MySQL, gets the result, writes it to Redis for future queries, and returns the response to the user.

Connection Configuration: Unix Domain Sockets vs TCP/IP

When setting up Redis on the same server as the website (localhost), using a TCP/IP network socket creates unnecessary overhead at the operating system level. Redis configuration documentation recommends using Unix domain sockets for local connections, which significantly reduces the load when configuring redis on the server.

Parameter TCP/IP (127.0.0.1:6379) Unix Socket (/var/run/redis/redis-server.sock)
Latency Higher (passing through the network stack) Minimal (IPC)
Capacity Limited by TCP stack Higher by 15–30% for local processes
Security Requires firewall/bind configuration Protected by file system permissions

1. Settings in redis.conf

unixsocket /var/run/redis/redis-server.sock unixsocketperm 770 # Disable TCP if Redis is running purely locally port 0

Make sure the user www-data (or PHP-FPM user) added to group redis to grant read and write permissions to the socket.

2. Configuration in wp-config.php

To ensure that the Redis Object Cache plugin in WordPress connects correctly via a Unix socket, add the following directives to the site's configuration file:

// Configure Redis connection via Unix Socket define('WP_REDIS_SCHEME', 'unix'); define('WP_REDIS_PATH', '/var/run/redis/redis-server.sock'); define('WP_REDIS_DATABASE', 0); // Redis database index

Memory Management: maxmemory and Eviction Policies

If Redis runs out of allocated RAM without a clearly defined eviction policy, it will start returning out of data errors (OOM command not allowed). According to Redis documentation on key displacement, for WordPress and WooCommerce it is critical to set it up correctly maxmemory-policy.

Recommended configurations in redis.conf:

maxmemory 512mb # Allocated amount depending on server RAM maxmemory-policy allkeys-lru
  • allkeys-lru: Removes the least recently used (LRU) keys from all available ones. Best choice for the default WordPress object cache.
  • volatile-lru: Deletes keys with a set expiration time (TTL). Suitable if Redis is also used for advanced persistence.

Key Isolation: Multisites and multiple projects on one server

A common mistake when running multiple WordPress sites on a single server with a single Redis instance is a lack of keyspace demarcation. This results in Site A receiving content or configuration from Site B.

To avoid key overlap, be sure to write a unique salt in the file wp-config.php for each site:

define('WP_CACHE_KEY_SALT', 'site1_prod_8f3a_');

Troubleshooting WooCommerce: Outdated Cache, Product Backlogs, and Race Conditions

During active sales or promotions, there is a risk of race conditions, when several buyers place orders for the same product at the same time. If the object cache of the remaining items is invalidated late, the buyer sees the product in stock, although it is no longer in stock.

Key steps for optimizing MySQL and Redis databases for WooCommerce:

  • Excluding non-cached groups (Non-persistent groups): Make sure WooCommerce sessions and cart transients are not cached indefinitely. Plugins should add counts, wc_session_id and transient to the list WP_REDIS_IGNORED_GROUPS as needed.
  • Clearing the woocommerce redis cache on import: If you are updating balances or prices via CSV/REST API, the built-in WordPress hooks do not always call `wp_cache_delete`. Use automated cleanup scripts after the bulk update is complete.
  • Fragmentation monitoring: Follow the parameter used_memory_rss in CLI (command redis-cli info memory) to make sure there are no memory leaks.

Redis Object Cache Implementation Checklist

Step Action Goal
1 Checking MySQL loading Determine whether queries to `wp_options` and meta tables are blocking.
2 Unix Socket Configuration Convert the connection from TCP (127.0.0.1) to a socket to reduce latency.
3 Key Isolation (`WP_CACHE_KEY_SALT`) Prevent conflicts between projects on the same server.
4 `maxmemory-policy` configuration Protect Redis from crashing due to an Out Of Memory error.
5 Checkout and cart testing Check for the absence of caching of personal data and leftovers.

When you need professional Redis server setup

Configuring redis woocommerce requires a balanced approach: a configuration error can lead to displaying other people's carts or incorrect display of prices. When choosing extensions, you should pay attention to proven solutions - more about this in our article about, how to use plugins safely.

Team VORONOV Solutions provides services for server optimization, caching system setup and comprehensive website optimization on WordPress/WooCommerce. All work is done transparently according to our approved tariffs: in the format of one-time hourly development (€35/hour), packages of hours, or as part of regular Development Retainer and Website Care support.

Frequently Asked Questions (FAQ)

What exactly does Redis Object Cache store, and what remains in MySQL?

Redis Object Cache stores in RAM the results of repeated SQL queries, parameter objects (table wp_options), post and product metadata (wp_postmeta), as well as transients. The MySQL database remains the primary and reliable place to store all data (orders, users, products), while Redis acts as a high-speed read buffer.

What is the difference between the free Redis Object Cache plugin and the Pro version for WooCommerce?

The free version implements the basic `WP_Object_Cache` functionality and is suitable for most standard sites. The Pro version includes specialized optimizations for WooCommerce: Fast-Events support, improved invalidation of the cache of remaining products, real-time query analytics, and protection against race conditions during peak loads.

How to properly clear the Redis cache in WooCommerce after bulk importing products?

When bulk importing via CSV or API, it is recommended to temporarily disable the object cache or perform a reset via WP-CLI after the procedure is complete using the command wp cache flush. This ensures that shoppers will immediately see up-to-date prices and product availability without the risk of reading outdated objects from RAM.