Skip to content
Gaurav TiwariDocs

wp-config.php Constants

Version 1.3.6 Updated October 26, 2026

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

ConstantEffect
GTPERF_SAFE_MODEAny truthy value turns safe mode on for the whole site
GTPERF_UNUSED_CSSAny 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' );
ConstantEffect
GTPERF_CLOUDFLARE_API_TOKENUsed instead of the saved token. When non-empty, it also forces token authentication
GTPERF_CLOUDFLARE_GLOBAL_API_KEYUsed instead of the saved Global API Key
GTPERF_CLOUDFLARE_EMAILUsed instead of the saved account email for Global API Key authentication
GTPERF_CLOUDFLARE_DOMAINDomain 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' );
ConstantEffect
GTPERF_XCLOUD_API_TOKENUsed instead of the saved xCloud API token
GTPERF_XCLOUD_API_BASE_URLAPI 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 );
ConstantOverrides setting
GTPERF_REDIS_ENABLEDredis.enabled. When defined, it wins over every other on/off signal below
GTPERF_REDIS_HOSTredis.host (hostname, IP, or Unix socket path)
GTPERF_REDIS_PORTredis.port (0 with a socket)
GTPERF_REDIS_DATABASEredis.database
GTPERF_REDIS_USERNAMEredis.username
GTPERF_REDIS_PASSWORDredis.password
GTPERF_REDIS_TLSredis.tls
GTPERF_REDIS_PERSISTENTredis.persistent
GTPERF_REDIS_PREFIXredis.prefix
GTPERF_REDIS_TIMEOUTredis.connection_timeout (seconds)
GTPERF_REDIS_READ_TIMEOUTredis.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.

ConstantEffect
WP_REDIS_HOSTHost
WP_REDIS_PORTPort
WP_REDIS_DATABASEDatabase number
WP_REDIS_PASSWORDA string password, or array( 'username', 'password' ) for ACL authentication
WP_REDIS_PREFIXKey prefix
WP_REDIS_TIMEOUTConnection timeout
WP_REDIS_READ_TIMEOUTRead timeout
WP_REDIS_SCHEMEtls, rediss or ssl turns TLS on; any other value turns it off. unix selects WP_REDIS_PATH
WP_REDIS_PATHUnix socket path. Used when WP_REDIS_SCHEME is unix or WP_REDIS_HOST is not defined; the port becomes 0
WP_REDIS_DISABLEDA truthy value turns the object cache off, unless GTPERF_REDIS_ENABLED is defined
WP_CACHE_KEY_SALTUsed as the key prefix when WP_REDIS_PREFIX is not defined

How the on/off decision is made

  1. GTPERF_REDIS_ENABLED, when defined, decides.
  2. Otherwise a truthy WP_REDIS_DISABLED turns Redis off.
  3. Otherwise defining GTPERF_REDIS_HOST, WP_REDIS_HOST or WP_REDIS_PATH turns Redis on.
  4. 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

ConstantEffect
WP_CACHEMust 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
DONOTCACHEPAGEA 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_DIRLocation of the cache root (WP_CONTENT_DIR/cache/gt-performance) and of both drop-ins
AUTH_KEYEncrypts 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_SALTWith AUTH_KEY, derives the key that encrypts saved secrets: the Cloudflare token and Global API Key, the Redis password, and the xCloud token
DB_NAMEPart of the default Redis key prefix
DISABLE_WP_CRONWhen 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_INTERVALThe 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_ENGINEsqlite, 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.

ConstantDetects
WC_VERSIONWooCommerce, for its commerce protections
EDD_VERSIONEasy Digital Downloads, for its commerce protections
FLUENTCART_VERSIONFluentCart, for its commerce protections
SPECULATION_RULES_VERSIONThe Speculative Loading plugin. When active, it owns speculation mode and GT Performance adds only its safety exclusions
WP_MCP_VERSIONThe 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.

ConstantValue
GTPERF_VERSIONPlugin version, for example 1.2.0
GTPERF_FILEAbsolute path of gt-performance.php
GTPERF_DIRAbsolute path of the plugin directory
GTPERF_BASENAMEgt-performance/gt-performance.php in a standard install
Share

Was this helpful?

Still stuck? Open a support ticket