Skip to content

Constants and filters

Shane Rounce edited this page Nov 30, 2026 · 8 revisions

Constants and filters

Constants go in wp-config.php, above the line that says to stop editing. Filters go in a plugin or your theme. A few filters run before ordinary plugins load, and say so: those must be in a must-use plugin.

Every name uses the single aceredis prefix: ACEREDIS_* constants, aceredis_* hooks and functions.

For worked examples of the hooks, see Hook examples.

Constants

The off switch

Constant Default What it does
ACEREDIS_DISABLED off true makes the plugin and both drop-ins stand aside for every request. No Redis connection is opened and no caching hooks are registered. The settings screen still loads and says the switch is set.

Connection

Constant Default What it does
ACEREDIS_HOST 127.0.0.1 Redis host for the drop-ins
ACEREDIS_PORT 6379 Redis port
ACEREDIS_PASSWORD none AUTH password
ACEREDIS_USERNAME none User name, for a Redis that uses access control lists
ACEREDIS_PREFIX none Object cache key prefix, to keep two installs on one database apart
ACEREDIS_PUBLIC_ESI_TOKEN none Dedicated origin secret shared with the Varnish configuration, at least 32 bytes. See Public text fragments.
ACEREDIS_CLUSTER_NODES none Redis Cluster seed addresses, separated by commas. The plugin and both drop-ins discover the other nodes. Use database 0.
ACEREDIS_BACKEND redis Selects the cache back end. A single-server site without Redis can use apcu.
ACEREDIS_SENTINELS none Sentinel addresses, separated by commas or new lines. Wins over the setting.
ACEREDIS_SENTINEL_SERVICE none The Sentinel service name. Wins over the setting.
ACEREDIS_SENTINEL_PASSWORD none Password for the sentinels themselves, if they have one. There is no setting for it.
ACEREDIS_SOCKET /var/run/redis/redis.sock Unix socket. Tried first when PHP can read it.
ACEREDIS_DB 0 Redis database number, used by the plugin and both drop-ins
ACEREDIS_USE_TLS off Object cache connects over TLS when it cannot read the saved settings
ACEREDIS_VERIFY_TLS off Object cache verifies the server certificate
ACEREDIS_TIMEOUT 0.5 Connect timeout, seconds
ACEREDIS_READ_TIMEOUT 0.5 Read timeout inside the plugin, seconds
ACEREDIS_OP_TIMEOUT 0.5 Time allowed for one Redis operation inside the plugin
ACEREDIS_MAX_RETRIES 2 Attempts per operation inside the plugin
ACEREDIS_SKIP_CONNECTION_TEST off true lets settings be saved with the cache on without testing the connection first. For hosts where wp-admin cannot reach Redis but the front end can.

A constant always wins over the matching setting. The page cache drop-in reads its Redis connection details from constants, so when your connection is not the default the settings screen and Site Health print the lines it needs. WP_REDIS_HOST, WP_REDIS_PORT and WP_REDIS_PASSWORD are honoured as fallbacks for the first three.

Page cache on a different Redis

Constant What it does
ACEREDIS_PAGE_HOST Host for the page cache drop-in only. 'tls://host' for TLS.
ACEREDIS_PAGE_PORT Its port
ACEREDIS_PAGE_PASSWORD Its password
ACEREDIS_PAGE_USERNAME Its user name
ACEREDIS_PAGE_DB Its database number

Use these when pages are stored somewhere other than the object cache, for example pages on a managed service and objects on a local socket. The object cache does not move.

Page cache

Constant Default What it does
WP_CACHE off WordPress's switch. Must be true for advanced-cache.php to load.
ACEREDIS_EARLY_SERVE off Serve hits from the drop-in before WordPress boots
ACEREDIS_EARLY_STALE on false sends stale pages to WordPress
ACEREDIS_EARLY_STALE_BLOCKS on false stops the drop-in using older copies of live blocks
ACEREDIS_EARLY_REFRESH_ADDR none Address the background block render connects to, for example '127.0.0.1'
ACEREDIS_EXIT_ON_HIT on false lets WordPress continue after a hit
ACEREDIS_CONDITIONAL on false stops page cache hits answering If-None-Match and If-Modified-Since with 304 Not Modified
ACEREDIS_BACKGROUND_LOCK unset Path of a lock file shared by every site on a server, so background page warming takes turns
ACEREDIS_DEBUG_TRACE off true, with WP_DEBUG, writes the plugin's internal trace lines to debug.log
ACEREDIS_BLOCK_CACHE unset true or false overrides the block cache setting
DONOTCACHEPAGE unset The usual WordPress signal. A page that defines it is neither served from cache nor stored.

Varnish and Cloudflare

Constant Default What it does
ACEREDIS_VARNISH setting true, false or 'auto'. Wins over the setting.
ACEREDIS_VARNISH_HOST setting 'host:port'. Wins over the setting.
ACEREDIS_CLOUDFLARE_ZONE setting Your Cloudflare zone ID
ACEREDIS_CLOUDFLARE_TOKEN setting Your Cloudflare API token, kept out of the database

Diagnostics

Constant Default What it does
ACEREDIS_HEALTH_COUNT on false stops the page cache drop-in counting hits for the Redis Health panel

Object cache

Constant Default What it does
ACEREDIS_LOCAL_TIER off Enable the local memory tier in front of Redis. Requires APCu.
ACEREDIS_LOCAL_TIER_TTL 5 Maximum age of a local copy, from 1 to 30 seconds.
ACEREDIS_OC_BYPASS off Turns the object cache off. The emergency switch.
ACEREDIS_OC_MAX_TTL setting Longest lifetime of any key, seconds. Wins over the setting. 0 for no cap.
ACEREDIS_OC_MEMBER_READ setting (on) Signed-in front-end requests read the shared cache
ACEREDIS_OC_ADMIN_READ setting (off) wp-admin screens read the shared cache
ACEREDIS_OC_WC_READ setting (off) Basket and checkout requests read the shared cache
ACEREDIS_OC_SHARED_TRANSIENTS on false stops signed-in and admin requests storing transients in Redis
ACEREDIS_OC_NO_PUBLIC_AJAX off true treats anonymous admin-ajax.php requests as admin requests
ACEREDIS_OC_FLUSH_ON_POST_CHANGE off true flushes the object cache on every post save, held to once a minute
ACEREDIS_OC_PROF off Records timings for the Diagnostics tab
ACEREDIS_OC_SLOW_LOG beside the PHP error log File that slow requests are logged to
ACEREDIS_OC_SLOW_LOG_MS 1500 Threshold in milliseconds. 0 turns the log off.
ACEREDIS_FORCE_TRANSIENT_FLUSH off Runs the transient flush that follows a post change in wp-admin requests too
WP_CACHE_KEY_SALT none WordPress's own. Part of the object cache key prefix.

Functions

Function Does
aceredis_refresh_urls( array $urls, $prime = true ) Refreshes known pages in place. Returns the number queued, or false.
aceredis_soft_purge_page_cache( $force = false ) Marks every page stale. Returns false when not possible.
aceredis_admin_cache_remember( $key, $compute, $tags, $ttl ) Caches a wp-admin read
aceredis_admin_cache_bump( $tag ) Drops wp-admin cache entries that depend on a tag
aceredis_add_persistent_groups( array $groups ) Keeps your own object cache groups in Redis. Exists only while the plugin's object-cache.php is active.
aceredis_add_write_through_groups( array $groups ) The same, for groups whose writes must reach Redis from signed-in and editing requests too
aceredis_cache() The plugin instance

Call them only after checking they exist, so your code works with the plugin off:

if ( function_exists( 'aceredis_refresh_urls' ) ) {
	aceredis_refresh_urls( $urls );
}

Actions you can fire

Action Does
do_action( 'aceredis_cache_purge_url', $url ) Deletes every stored copy of one page
do_action( 'aceredis_start_page_cache' ) Starts the page cache on a custom route, before any output
do_action( 'aceredis_cache_varnish_ban_site' ) Bans the whole site in Varnish

Actions you can listen to

Action Fired when
aceredis_paths_invalidated Specific paths were purged. Receives the paths.
aceredis_cache_tags_invalidated A post changed. Receives the cache tags for that post and the listings that may show it, and the post ID.
aceredis_cache_cleared The cache was cleared
aceredis_page_epoch_bumped A soft purge marked every page stale
aceredis_post_transients_flushed A post's transients were flushed
aceredis_all_transients_flushed All transients were flushed

Filters

What is cached

Filter Default Changes
aceredis_cache_excluded_urls [] Strings that exclude a URL from the page cache when it contains one
aceredis_skip_page_cache_store computed Whether this response is kept out of the cache
aceredis_page_store_block_reason null Return a reason to refuse storing this page
aceredis_min_main_text_bytes 400 Least text the main content must hold
aceredis_min_structured_text_bytes 40 Least text a short main area must hold when it is real content: a heading, a paragraph, a list
aceredis_main_content_marker a class name Class that marks the main content element
aceredis_crawler_bypass none ['agents' => regex, 'paths' => [...]]: crawlers served live on those paths
aceredis_early_bypass_paths shop paths Paths the drop-in always sends to WordPress
aceredis_enable_first_pass_skip false Return true to store a page on its second view, as versions before 0.10.6 did when the transient cache was off
aceredis_cache_page_cache_key_parts computed The parts of a page key. Receives the parts and the request URI, scheme, device and host.
aceredis_expose_bypass_reason true Return false to leave the reason out of the X-AceRedisCache header
aceredis_conditional_requests true Return false to stop hits answering conditional requests with 304

Lifetimes

Filter Default Changes
aceredis_page_ttl setting Fresh lifetime for a URL
aceredis_page_grace setting Grace window for a URL
aceredis_page_ttl_jitter setting Jitter percentage
aceredis_cache_ttl setting Base cache TTL
aceredis_browser_max_age 300 Browser max-age on a hit
aceredis_dynamic_stale_ttl 20 x the microcache TTL, 300 to 3600 Seconds an older copy of a live block is kept

Live blocks

Filter Changes
aceredis_dynamic_block_patterns Block name patterns treated as live. From 0.10.6 it runs even when the Block Exclusions setting is empty, so a block can be kept live from code alone.
aceredis_dynamic_placeholder_limit Most live blocks handled per page
aceredis_enable_partial_dynamic Whether live blocks are on

Purging, refresh and warming

Filter Default Changes
aceredis_public_fragments empty list Register public text callbacks and their lifetimes by slug.
aceredis_offline_provider_active false Return true when an existing web app is responsible for offline support.
aceredis_warm_paused false Return true to pause cache warmer checks.
aceredis_warm_urls computed URLs considered by the cache warmer. The configured list cap still applies.
aceredis_recache_on_edit true Whether edits recache pages at all
aceredis_recache_urls computed URLs refreshed for an edited post
aceredis_recache_related_urls computed Listing pages that show the post
aceredis_recache_max_urls 100 Most URLs refreshed per edit
aceredis_sitewide_recache_post_types templates, navigation, styles Post types whose edits make the whole site stale
aceredis_post_invalidation_paths computed Paths purged for a post
aceredis_post_archive_invalidation_paths computed Archive paths purged for a post
aceredis_defer_post_invalidation true Whether purges are queued for cron, not run in the save
aceredis_soft_broad_purge depends on the caller Whether a site-wide purge is soft when a grace window exists
aceredis_soft_purge_min_interval 300 Seconds within which soft purges are folded into one
aceredis_enable_cache_priming true Whether refreshed pages are rendered now or only marked stale
aceredis_prime_parallel 3 Pages rendered at once
aceredis_prime_timeout 25 Seconds allowed per render
aceredis_prime_time_budget 20 (120 on the command line) Seconds per refresher run
aceredis_sitemap_prime_urls computed URLs the sitemap warmer renders
aceredis_sitemap_prime_batch_size 10 URLs per batch
aceredis_sitemap_prime_delay 300 Seconds between batches
aceredis_woocommerce_warm_urls best sellers Shop URLs warmed after a clear
aceredis_background_lock_file none The shared lock file for background warming

Object cache

These run as WordPress starts its object cache. Add them from a must-use plugin.

Filter Changes
aceredis_local_tier_groups Additional object cache groups to keep briefly in APCu when the local tier is enabled. The default list is empty.
aceredis_oc_persistent_groups Groups stored in Redis
aceredis_oc_bypass_groups Groups never stored in Redis
aceredis_object_cache_bypass Whether this request skips Redis. Receives what kind of request it is.
aceredis_oc_member_read_mode Whether this signed-in request may read the shared cache
aceredis_oc_flush_on_post_change Whether a post save flushes the object cache
aceredis_object_cache_write_through_groups Groups whose changes always reach Redis

Transients

Filter Changes
aceredis_cache_transient_exclusions Transient patterns never stored in Redis
aceredis_post_transient_patterns Transients flushed when a post changes
aceredis_transient_global_flush_on_post_change Whether a post change may flush transients site-wide
aceredis_force_transient_flush Force that flush in wp-admin requests

Signed-in page cache

Filter Changes
aceredis_logged_in_cache_group The group a user's copy is stored under. Return null to never serve that user a stored copy.
aceredis_logged_in_store_block Return a reason to refuse storing a signed-in page

Block cache

Filter Changes
aceredis_block_cache_enabled On or off
aceredis_block_cache_cacheable Whether one block is cached
aceredis_block_cache_profiles The profiles: block lists, lifetimes and rules
aceredis_block_cache_custom_blocks Block names in the Custom group
aceredis_block_cache_woo_blocks Block names in the WooCommerce group
aceredis_block_cache_context_blocks Blocks that read the page and are not cached
aceredis_block_cache_vary Extra key parts
aceredis_block_cache_woo_role_safe, aceredis_block_cache_custom_role_safe Whether a group may be cached per role

Varnish

Filter Changes
aceredis_varnish_enabled On or off
aceredis_varnish_hosts The Varnish servers to tell
aceredis_varnish_ban_on_refresh Whether a background refresh bans its page

Edge caches

Filter Changes
aceredis_cache_tags The cache tags sent for a page
aceredis_cache_tag_prefix The short per-site code every tag starts with
aceredis_cache_tag_headers Which headers carry the tags
aceredis_cache_tag_max_length The longest tag header sent
aceredis_cloudflare_allow_purge_everything Return true to let a full clear purge the whole Cloudflare zone. Off, because a zone can hold other sites.
aceredis_cloudflare_purge_by_tag Whether Cloudflare is purged by tag when cache tag headers are on
aceredis_cloudflare_hosts The host names purged at Cloudflare

Abilities

Filter Changes
aceredis_abilities_expose_to_agents Return true to offer the plugin's abilities to AI agents

Compression

Filter Default
aceredis_brotli_level_page 9
aceredis_brotli_level_object 5
aceredis_gzip_level_page 6
aceredis_gzip_level_object 6
aceredis_min_compress_size 512 bytes

wp-admin

Filter Changes
aceredis_admin_query_cache_enabled Whether the wp-admin query cache runs
aceredis_opcache_prime_files Files to prime in OPcache. The helper skips files PHP already loaded or cached and resolves duplicate paths to the same file. The REST response lists the files compiled during that request.

HTML rewrites

Not one of the plugin's own hooks, but the one that matters most to anything that changes page HTML. Use WordPress's response filter, so your change is part of what is stored:

add_filter( 'wp_template_enhancement_output_buffer', 'my_rewrite', 5 );

Clone this wiki locally