wp-config.php Constants
Every constant the plugin or its drop-ins read. Define them in wp-config.php, above the /* That's all, stop editing! */ line. Constants are the right tool for per-environment configuration and for keeping secrets out of the database.
Every GT Performance constant uses the GTPERF_ prefix. Nothing reads a GTP_ constant. See Upgrading if an old wp-config.php still has them.
Safety switches
| Constant | Effect |
|---|---|
GTPERF_SAFE_MODE | Any truthy value turns safe mode on for the whole site |
GTPERF_UNUSED_CSS | Any truthy value enables the unused-CSS engine even when Remove unused CSS is off. Meant for staging |
define( 'GTPERF_SAFE_MODE', true );
Safe mode stops every HTML transformation (all six optimization stages and CDN URL rewriting), stops serving minified JavaScript, pauses CSS regeneration, and stops the page cache: the advanced-cache.php drop-in reads the constant too and serves nothing from the cache, and WordPress stores nothing and sends Cache-Control: no-store, private, max-age=0 and X-GT-Cache: SAFE-MODE. It changes no setting, drop-in, WP_CACHE or stored page, so removing the line restores everything. See Troubleshooting.
Source: src/Core/SafeMode.php
Cloudflare
define( 'GTPERF_CLOUDFLARE_API_TOKEN', 'scoped-token' );
// or, legacy:
define( 'GTPERF_CLOUDFLARE_GLOBAL_API_KEY', 'global-key' );
define( 'GTPERF_CLOUDFLARE_EMAIL', 'you@example.com' );
define( 'GTPERF_CLOUDFLARE_DOMAIN', 'example.com' );
| Constant | Effect |
|---|---|
GTPERF_CLOUDFLARE_API_TOKEN | Used instead of the saved token. When non-empty, it also forces token authentication |
GTPERF_CLOUDFLARE_GLOBAL_API_KEY | Used instead of the saved Global API Key |
GTPERF_CLOUDFLARE_EMAIL | Used instead of the saved account email for Global API Key authentication |
GTPERF_CLOUDFLARE_DOMAIN | Domain used to look up the zone when no Zone ID is saved. Without it, the saved domain, then the home URL’s host |
Authentication mode is chosen in this order: a non-empty token constant means token; otherwise non-empty key and email constants mean Global API Key; otherwise the Authentication setting decides.
The constants supply credentials only. Enable Cloudflare integration still has to be on, and the rule still has to be synced. See Cloudflare.
Source: src/Cloudflare/ClientFactory.php
xCloud
define( 'GTPERF_XCLOUD_API_TOKEN', 'token' );
define( 'GTPERF_XCLOUD_API_BASE_URL', 'https://app.xcloud.host' );
| Constant | Effect |
|---|---|
GTPERF_XCLOUD_API_TOKEN | Used instead of the saved xCloud API token |
GTPERF_XCLOUD_API_BASE_URL | API base URL. Defaults to https://app.xcloud.host; a trailing slash is removed |
Enable xCloud cache integration still has to be on. See xCloud.
Source: src/XCloud/ClientFactory.php
Redis
Read by the admin screen and connection test (src/Redis/Configuration.php) and, on every request, by the object-cache.php drop-in (dropins/object-cache.php).
Precedence: GTPERF_REDIS_*, then WP_REDIS_*, then the saved Object Cache settings.
GT Performance constants
define( 'GTPERF_REDIS_ENABLED', true );
define( 'GTPERF_REDIS_HOST', '127.0.0.1' );
define( 'GTPERF_REDIS_PORT', 6379 );
define( 'GTPERF_REDIS_DATABASE', 0 );
define( 'GTPERF_REDIS_USERNAME', 'user' );
define( 'GTPERF_REDIS_PASSWORD', 'secret' );
define( 'GTPERF_REDIS_TLS', true );
define( 'GTPERF_REDIS_PERSISTENT', true );
define( 'GTPERF_REDIS_PREFIX', 'example:' );
define( 'GTPERF_REDIS_TIMEOUT', 0.5 );
define( 'GTPERF_REDIS_READ_TIMEOUT', 0.5 );
| Constant | Overrides setting |
|---|---|
GTPERF_REDIS_ENABLED | redis.enabled. When defined, it wins over every other on/off signal below |
GTPERF_REDIS_HOST | redis.host (hostname, IP, or Unix socket path) |
GTPERF_REDIS_PORT | redis.port (0 with a socket) |
GTPERF_REDIS_DATABASE | redis.database |
GTPERF_REDIS_USERNAME | redis.username |
GTPERF_REDIS_PASSWORD | redis.password |
GTPERF_REDIS_TLS | redis.tls |
GTPERF_REDIS_PERSISTENT | redis.persistent |
GTPERF_REDIS_PREFIX | redis.prefix |
GTPERF_REDIS_TIMEOUT | redis.connection_timeout (seconds) |
GTPERF_REDIS_READ_TIMEOUT | redis.read_timeout (seconds) |
Redis Object Cache compatible constants
The WP_REDIS_* constants used by Till Krüss’s Redis Object Cache plugin are honored, so an existing configuration keeps working.
| Constant | Effect |
|---|---|
WP_REDIS_HOST | Host |
WP_REDIS_PORT | Port |
WP_REDIS_DATABASE | Database number |
WP_REDIS_PASSWORD | A string password, or array( 'username', 'password' ) for ACL authentication |
WP_REDIS_PREFIX | Key prefix |
WP_REDIS_TIMEOUT | Connection timeout |
WP_REDIS_READ_TIMEOUT | Read timeout |
WP_REDIS_SCHEME | tls, rediss or ssl turns TLS on; any other value turns it off. unix selects WP_REDIS_PATH |
WP_REDIS_PATH | Unix socket path. Used when WP_REDIS_SCHEME is unix or WP_REDIS_HOST is not defined; the port becomes 0 |
WP_REDIS_DISABLED | A truthy value turns the object cache off, unless GTPERF_REDIS_ENABLED is defined |
WP_CACHE_KEY_SALT | Used as the key prefix when WP_REDIS_PREFIX is not defined |
How the on/off decision is made
GTPERF_REDIS_ENABLED, when defined, decides.- Otherwise a truthy
WP_REDIS_DISABLEDturns Redis off. - Otherwise defining
GTPERF_REDIS_HOST,WP_REDIS_HOSTorWP_REDIS_PATHturns Redis on. - Otherwise Enable Redis object cache decides.
With no prefix from any source, the drop-in uses gtperf: followed by an MD5 hash of DB_NAME and ABSPATH, so two installs on one Redis database do not share keys. See Redis Object Cache.
WordPress constants the plugin reads
| Constant | Effect |
|---|---|
WP_CACHE | Must be true for WordPress to load advanced-cache.php, and for the plugin to store pages at all. Installing the drop-in adds define( 'WP_CACHE', true ); // Added by GT Performance to wp-config.php, or rewrites an existing WP_CACHE line and remembers the original. Deactivating the plugin removes its drop-ins and restores that line |
DONOTCACHEPAGE | A truthy value at the end of the response keeps that page out of the cache and sends no-store headers, including CDN-Cache-Control and Cloudflare-CDN-Cache-Control |
WP_CONTENT_DIR | Location of the cache root (WP_CONTENT_DIR/cache/gt-performance) and of both drop-ins |
AUTH_KEY | Encrypts the runtime files config.json and redis-config.json, and keys the HMAC on the X-GT-Preload token that lets the plugin’s own preloads rebuild stale pages. It must be at least 16 characters and not the sample phrase, and PHP needs OpenSSL, or saving settings fails with a runtime-configuration error. Setup checks both |
SECURE_AUTH_SALT | With AUTH_KEY, derives the key that encrypts saved secrets: the Cloudflare token and Global API Key, the Redis password, and the xCloud token |
DB_NAME | Part of the default Redis key prefix |
DISABLE_WP_CRON | When true, doctor and the health report check for overdue cron events and suggest a system cron line. The queue then depends on that cron. See Diagnostics |
AUTOSAVE_INTERVAL | The Autosave interval setting defines this during plugins_loaded, ahead of WordPress core’s 60-second default, when the setting is not 60 and nothing has defined it yet. A value set in wp-config.php wins |
DB_ENGINE | sqlite, or a WP_SQLite_DB database object, switches the plugin’s named locks to an implementation that works without MySQL advisory locks, as on WordPress Studio and Playground |
Rotating AUTH_KEY makes the existing runtime files unreadable. Until the settings are saved again, the page-cache drop-in serves nothing and the Redis drop-in falls back to what the constants alone define. Rotating AUTH_KEY or SECURE_AUTH_SALT also makes saved secrets unreadable; enter the Cloudflare, Redis and xCloud credentials again, or supply them as constants.
Sources: src/Cache/ConfigFile.php, src/Core/SecretCipher.php, dropins/advanced-cache.php
Constants from other plugins
Read only to detect what is active. You never need to define these.
| Constant | Detects |
|---|---|
WC_VERSION | WooCommerce, for its commerce protections |
EDD_VERSION | Easy Digital Downloads, for its commerce protections |
FLUENTCART_VERSION | FluentCart, for its commerce protections |
SPECULATION_RULES_VERSION | The Speculative Loading plugin. When active, it owns speculation mode and GT Performance adds only its safety exclusions |
WP_MCP_VERSION | The WordPress MCP Adapter version, shown on the AI & MCP tab and by wp gt-performance abilities status |
Defined by the plugin
Not for you to set. Listed because they appear in stack traces and in the drop-ins’ runtime configuration.
| Constant | Value |
|---|---|
GTPERF_VERSION | Plugin version, for example 1.2.0 |
GTPERF_FILE | Absolute path of gt-performance.php |
GTPERF_DIR | Absolute path of the plugin directory |
GTPERF_BASENAME | gt-performance/gt-performance.php in a standard install |