Skip to content

Redis Object Cache

Gaurav Tiwari edited this page Aug 27, 2026 · 1 revision

Redis Object Cache

An owned object-cache.php drop-in backing WordPress's object cache with Redis. Complements the page cache — it speeds up the requests that cannot be cached, which on a store is most of the important ones.

Off by default.

Install

  1. Ensure the PHP redis extension is present.
  2. Enter connection details under Integrations → Redis object cache, or define constants in wp-config.php.
  3. Click Test and install Redis.

Installation runs a connection test first and refuses rather than installing a drop-in that cannot connect. A broken object-cache drop-in degrades every request on the site, so this is deliberately not a one-click-and-hope operation.

If another plugin already owns object-cache.php, GT Performance will not overwrite it.

Configuration

Setting Default
Host / socket 127.0.0.1
Port 6379
Database 0
Username / password empty, encrypted at rest
TLS off
Persistent connections on
Key prefix automatic, site-specific
Connection timeout 0.5s
Read timeout 0.5s

Use a unique prefix whenever several WordPress installs share one Redis database. Left blank, the drop-in derives one from the database name and path.

Constants

GTPERF_REDIS_* constants take highest precedence, and the WP_REDIS_* constants used by Till Krüss's Redis Object Cache are honoured too, so an existing configuration keeps working unchanged. Full list and precedence order: Constants Reference.

How the drop-in reads its configuration

object-cache.php has no plugin dependency by design — it must define the global wp_cache_*() API before anything else loads. It reads wp-content/cache/gt-performance/redis-config.json.php, which is inert JSON behind a <?php exit; ?> guard, with file_get_contents() and json_decode(). It is never included or executed.

That file holds a host, username and password, which is exactly why it keeps a .php extension: a direct web request is terminated by the PHP interpreter itself, on any server, including one that ignores .htaccess. See Architecture.

Timeouts

Both default to 0.5 seconds, and that is deliberate. A Redis instance that has gone away should degrade WordPress to a non-persistent cache quickly, not hold every request open for several seconds. If you are on a network where 0.5s is genuinely too tight, raise it — but treat a needed increase as a signal about the network rather than a tuning win.

Removing it

Deactivating the plugin removes the drop-in. WP_REDIS_DISABLED is the emergency off switch that does not require touching the plugin at all.

Related

Constants Reference · Architecture · Diagnostics

Clone this wiki locally