Complete documentation for WordPress filters, action hooks, WP-CLI commands, and REST API endpoints available in the Mamba Performance plugin.
Overview
Mamba Performance provides extensive hooks and APIs for developers to customize caching behavior, integrate with external systems, and automate cache management. This reference covers all available extension points.
Caching & TTL Filters
Control cache duration, behavior, and page-level caching decisions.
Modify the cache TTL (time-to-live) in seconds for any cached response.
| Parameter | Type | Description |
|---|---|---|
$ttl | int | Cache duration in seconds |
$url | string | The URL being cached |
add_filter('mamba_cache_ttl', function($ttl, $url) {
if (strpos($url, '/shop/') !== false) {
return 1800; // 30 minutes for shop pages
}
return $ttl;
}, 10, 2);Set the default TTL for all cached pages when no specific TTL is configured.
| Parameter | Type | Description |
|---|---|---|
$ttl | int | Default cache duration in seconds |
add_filter('mamba_default_ttl', function($ttl) {
return 43200; // 12 hours
}, 10, 1);Determine whether the current page should be cached. Return false to bypass caching.
| Parameter | Type | Description |
|---|---|---|
$should_cache | bool | Whether to cache the page |
add_filter('mamba_should_cache_page', function($should_cache) {
if (is_user_logged_in() && current_user_can('edit_posts')) {
return false; // Don't cache for editors
}
return $should_cache;
}, 10, 1);Modify the Cache-Control header value sent with cached responses.
| Parameter | Type | Description |
|---|---|---|
$header | string | Cache-Control header value |
$ttl | int | Current TTL in seconds |
add_filter('mamba_cache_control_header', function($header, $ttl) {
return "public, max-age={$ttl}, stale-while-revalidate=60";
}, 10, 2);Set the stale-while-revalidate duration for cache headers.
| Parameter | Type | Description |
|---|---|---|
$swr | int | Stale-while-revalidate duration in seconds |
$ttl | int | Current TTL |
add_filter('mamba_stale_while_revalidate', function($swr, $ttl) {
return 3600; // 1 hour stale-while-revalidate
}, 10, 2);Set the stale-if-error duration for cache headers.
| Parameter | Type | Description |
|---|---|---|
$sie | int | Stale-if-error duration in seconds |
$ttl | int | Current TTL |
add_filter('mamba_stale_if_error', function($sie, $ttl) {
return 86400; // Serve stale for 24h on error
}, 10, 2);Cache Variants
Control how cache variations are created based on cookies, headers, and query parameters.
Specify which cookies should create separate cache variants.
| Parameter | Type | Description |
|---|---|---|
$cookies | array | Array of cookie names to vary on |
add_filter('mamba_vary_cookies', function($cookies) {
$cookies[] = 'my_custom_cookie';
return $cookies;
}, 10, 1);Specify which HTTP headers should create separate cache variants.
| Parameter | Type | Description |
|---|---|---|
$headers | array | Array of header names to vary on |
add_filter('mamba_vary_headers', function($headers) {
$headers[] = 'X-Custom-Header';
return $headers;
}, 10, 1);Modify the cache key used for storing and retrieving cached responses.
| Parameter | Type | Description |
|---|---|---|
$key | string | The generated cache key |
$url | string | The URL being cached |
add_filter('mamba_cache_key', function($key, $url) {
if (wp_is_mobile()) {
return $key . '_mobile';
}
return $key;
}, 10, 2);Query parameters to ignore when generating cache keys (e.g., tracking parameters).
| Parameter | Type | Description |
|---|---|---|
$params | array | Array of query parameter names to ignore |
add_filter('mamba_ignored_query_params', function($params) {
$params[] = 'fbclid';
$params[] = 'gclid';
$params[] = 'utm_source';
return $params;
}, 10, 1);Cache Invalidation
Control when and how cache is invalidated based on content changes.
Modify the list of URLs to purge when content changes.
| Parameter | Type | Description |
|---|---|---|
$urls | array | Array of URLs to purge |
$post_id | int | The post ID that triggered the purge |
add_filter('mamba_purge_urls', function($urls, $post_id) {
$urls[] = home_url('/custom-page/');
return $urls;
}, 10, 2);URLs to purge when a specific post is updated.
| Parameter | Type | Description |
|---|---|---|
$urls | array | Array of URLs to purge |
$post | WP_Post | The post object |
add_filter('mamba_purge_post_urls', function($urls, $post) {
if ($post->post_type === 'product') {
$urls[] = wc_get_page_permalink('shop');
}
return $urls;
}, 10, 2);Modify cache tags assigned to a response for tag-based invalidation.
| Parameter | Type | Description |
|---|---|---|
$tags | array | Array of cache tags |
$url | string | The URL being cached |
add_filter('mamba_cache_tags', function($tags, $url) {
if (is_product()) {
global $product;
$tags[] = 'product_' . $product->get_id();
}
return $tags;
}, 10, 2);Post types that trigger cache invalidation when updated.
| Parameter | Type | Description |
|---|---|---|
$post_types | array | Array of post type slugs |
add_filter('mamba_invalidation_post_types', function($post_types) {
$post_types[] = 'my_custom_post_type';
return $post_types;
}, 10, 1);Store API Caching
Control caching behavior for WooCommerce Store API endpoints.
Enable or disable Store API caching globally.
| Parameter | Type | Description |
|---|---|---|
$enabled | bool | Whether Store API caching is enabled |
add_filter('mamba_store_api_cache_enabled', '__return_false');Set the TTL for Store API responses.
| Parameter | Type | Description |
|---|---|---|
$ttl | int | Cache duration in seconds |
$route | string | The API route being cached |
add_filter('mamba_store_api_ttl', function($ttl, $route) {
if (strpos($route, '/products') !== false) {
return 3600; // 1 hour for products
}
return $ttl;
}, 10, 2);Define which Store API routes are cacheable.
| Parameter | Type | Description |
|---|---|---|
$routes | array | Array of cacheable route patterns |
add_filter('mamba_store_api_cacheable_routes', function($routes) {
$routes[] = '/wc/store/v1/custom-endpoint';
return $routes;
}, 10, 1);Routes to exclude from Store API caching.
| Parameter | Type | Description |
|---|---|---|
$routes | array | Array of route patterns to exclude |
add_filter('mamba_store_api_excluded_routes', function($routes) {
$routes[] = '/wc/store/v1/checkout';
return $routes;
}, 10, 1);Headers to vary Store API cache on.
| Parameter | Type | Description |
|---|---|---|
$headers | array | Array of header names |
add_filter('mamba_store_api_vary_headers', function($headers) {
$headers[] = 'X-Customer-Group';
return $headers;
}, 10, 1);Warmup & Preloading
Control cache warming behavior and URL discovery.
Modify the list of URLs to warm up.
| Parameter | Type | Description |
|---|---|---|
$urls | array | Array of URLs to warm |
add_filter('mamba_warmup_urls', function($urls) {
$urls[] = home_url('/important-landing-page/');
return $urls;
}, 10, 1);Number of URLs to warm per batch.
| Parameter | Type | Description |
|---|---|---|
$size | int | Batch size |
add_filter('mamba_warmup_batch_size', function($size) {
return 20; // Process 20 URLs per batch
}, 10, 1);Number of concurrent warmup requests.
| Parameter | Type | Description |
|---|---|---|
$concurrency | int | Number of concurrent requests |
add_filter('mamba_warmup_concurrency', function($concurrency) {
return 5; // 5 concurrent requests
}, 10, 1);Delay between warmup batches in milliseconds.
| Parameter | Type | Description |
|---|---|---|
$delay | int | Delay in milliseconds |
add_filter('mamba_warmup_delay', function($delay) {
return 500; // 500ms between batches
}, 10, 1);Timeout for warmup requests in seconds.
| Parameter | Type | Description |
|---|---|---|
$timeout | int | Timeout in seconds |
add_filter('mamba_warmup_timeout', function($timeout) {
return 30; // 30 second timeout
}, 10, 1);Post types to include in warmup URL discovery.
| Parameter | Type | Description |
|---|---|---|
$post_types | array | Array of post type slugs |
add_filter('mamba_warmup_post_types', function($post_types) {
$post_types[] = 'portfolio';
return $post_types;
}, 10, 1);CDN Integration
Configure CDN behavior and cache tag management.
Enable or disable CDN integration.
| Parameter | Type | Description |
|---|---|---|
$enabled | bool | Whether CDN is enabled |
add_filter('mamba_cdn_enabled', function($enabled) {
return !is_admin(); // Only enable CDN on frontend
}, 10, 1);Modify the CDN URL used for assets.
| Parameter | Type | Description |
|---|---|---|
$cdn_url | string | The CDN base URL |
add_filter('mamba_cdn_url', function($cdn_url) {
return 'https://cdn.example.com';
}, 10, 1);Modify CDN cache tags for tag-based purging.
| Parameter | Type | Description |
|---|---|---|
$tags | array | Array of cache tags |
add_filter('mamba_cdn_cache_tags', function($tags) {
$tags[] = 'custom_tag_' . get_current_blog_id();
return $tags;
}, 10, 1);File extensions to exclude from CDN rewriting.
| Parameter | Type | Description |
|---|---|---|
$extensions | array | Array of file extensions |
add_filter('mamba_cdn_excluded_extensions', function($extensions) {
$extensions[] = 'pdf';
return $extensions;
}, 10, 1);Media & LCP Optimization
Control image optimization and Largest Contentful Paint detection.
Enable or disable LCP optimization.
| Parameter | Type | Description |
|---|---|---|
$enabled | bool | Whether LCP optimization is enabled |
add_filter('mamba_lcp_enabled', '__return_true');Override the detected LCP image for a page.
| Parameter | Type | Description |
|---|---|---|
$image_url | string | The LCP image URL |
$url | string | The page URL |
add_filter('mamba_lcp_image', function($image_url, $url) {
if (is_front_page()) {
return get_template_directory_uri() . '/images/hero.webp';
}
return $image_url;
}, 10, 2);Enable or disable lazy loading for images.
| Parameter | Type | Description |
|---|---|---|
$enabled | bool | Whether lazy loading is enabled |
add_filter('mamba_lazy_load_enabled', function($enabled) {
return !is_product(); // Disable on product pages
}, 10, 1);Set the lazy load threshold (distance from viewport).
| Parameter | Type | Description |
|---|---|---|
$threshold | string | Threshold value (e.g., ‘200px’) |
add_filter('mamba_lazy_load_threshold', function($threshold) {
return '300px';
}, 10, 1);DNS Prefetch & Preconnect
Control DNS prefetching and preconnect hints.
URLs to add DNS prefetch hints for.
| Parameter | Type | Description |
|---|---|---|
$urls | array | Array of URLs to prefetch |
add_filter('mamba_dns_prefetch_urls', function($urls) {
$urls[] = 'https://api.example.com';
return $urls;
}, 10, 1);URLs to add preconnect hints for.
| Parameter | Type | Description |
|---|---|---|
$urls | array | Array of URLs to preconnect |
add_filter('mamba_preconnect_urls', function($urls) {
$urls[] = ['url' => 'https://fonts.googleapis.com', 'crossorigin' => true];
return $urls;
}, 10, 1);Database Optimization
Control database cleanup and optimization tasks.
Enable or disable automatic database cleanup.
| Parameter | Type | Description |
|---|---|---|
$enabled | bool | Whether cleanup is enabled |
add_filter('mamba_db_cleanup_enabled', '__return_false');Modify the list of database cleanup tasks.
| Parameter | Type | Description |
|---|---|---|
$tasks | array | Array of cleanup task identifiers |
add_filter('mamba_db_cleanup_tasks', function($tasks) {
unset($tasks['revisions']); // Keep revisions
return $tasks;
}, 10, 1);Age threshold for cleaning expired transients.
| Parameter | Type | Description |
|---|---|---|
$days | int | Days before transients are cleaned |
add_filter('mamba_db_transient_expiry', function($days) {
return 7; // Clean transients older than 7 days
}, 10, 1);Admin & Permissions
Control admin interface and user permissions.
Required capability to access Mamba admin pages.
| Parameter | Type | Description |
|---|---|---|
$capability | string | WordPress capability |
add_filter('mamba_admin_capability', function($capability) {
return 'manage_woocommerce'; // Allow shop managers
}, 10, 1);Required capability to purge cache.
| Parameter | Type | Description |
|---|---|---|
$capability | string | WordPress capability |
add_filter('mamba_purge_capability', function($capability) {
return 'edit_posts'; // Allow editors to purge
}, 10, 1);Show or hide Mamba in the admin bar.
| Parameter | Type | Description |
|---|---|---|
$enabled | bool | Whether to show admin bar item |
add_filter('mamba_admin_bar_enabled', '__return_false');Action Hooks
Hook into Mamba events for custom integrations.
Triggered when purging by CDN tags.
| Parameter | Type | Description |
|---|---|---|
$tags | array | Array of cache tags being purged |
add_action('mamba_purge_tags', function($tags) {
error_log('Mamba purged tags: ' . implode(', ', $tags));
}, 10, 1);Triggered when purging specific URLs.
| Parameter | Type | Description |
|---|---|---|
$urls | array | Array of URLs being purged |
$headerCombos | array | Header combinations (optional) |
add_action('mamba_purge_urls', function($urls, $headerCombos = []) {
foreach ($urls as $url) {
error_log('Mamba purged URL: ' . $url);
}
}, 10, 2);Triggered after the full cache has been purged.
add_action('mamba_cache_purged', function() {
error_log('Mamba cache was fully purged');
});Triggered when a full cache purge is performed.
add_action('mamba_purge_all', function() {
// Notify external systems of full cache clear
});Triggered when the Store API cache is cleared.
add_action('mamba_store_api_cleared', function() {
error_log('Mamba Store API cache was cleared');
});Triggered when a database optimization task completes.
| Parameter | Type | Description |
|---|---|---|
$taskId | string | Task identifier |
$affected | int | Number of rows affected |
add_action('mamba_db_task_completed', function($taskId, $affected) {
error_log("Mamba DB task {$taskId}: {$affected} rows affected");
}, 10, 2);Triggered when a cache-related error occurs.
| Parameter | Type | Description |
|---|---|---|
$message | string | Error message |
$context | array | Additional context |
add_action('mamba_cache_error', function($message, $context = []) {
error_log('Mamba error: ' . $message);
}, 10, 2);WP-CLI Commands
Manage Mamba cache from the command line.
Purge all cached pages and Store API responses.
| Option | Description |
|---|---|
--store-api | Only purge Store API cache |
--pages | Only purge page cache |
# Purge all cache
wp mamba purge
# Purge only Store API cache
wp mamba purge --store-api
# Purge only page cache
wp mamba purge --pagesPurge a specific URL from cache.
| Argument | Description |
|---|---|
<url> | The URL to purge (required) |
wp mamba purge url https://example.com/shop/Warm up the cache by pre-fetching URLs.
| Option | Description |
|---|---|
--limit=<n> | Maximum URLs to warm (default: all) |
--type=<type> | Content type: posts, products, categories |
--concurrency=<n> | Concurrent requests (default: 3) |
# Warm all URLs
wp mamba warmup
# Warm only products with limit
wp mamba warmup --type=products --limit=100
# Warm with higher concurrency
wp mamba warmup --concurrency=5Display cache status and statistics.
| Option | Description |
|---|---|
--format=<format> | Output format: table, json, csv |
# Display status table
wp mamba status
# Get JSON output
wp mamba status --format=jsonRun database optimization tasks.
| Option | Description |
|---|---|
--task=<task> | Specific task: transients, revisions, orphans |
--dry-run | Preview changes without executing |
# Run all optimization tasks
wp mamba db optimize
# Preview transient cleanup
wp mamba db optimize --task=transients --dry-run
# Clean only revisions
wp mamba db optimize --task=revisionsView or modify Mamba configuration.
| Subcommand | Description |
|---|---|
get <key> | Get a configuration value |
set <key> <value> | Set a configuration value |
list | List all configuration |
# List all config
wp mamba config list
# Get specific value
wp mamba config get default_ttl
# Set a value
wp mamba config set default_ttl 43200REST API Endpoints
Programmatically manage cache via REST API. All endpoints require authentication with manage_options capability.
Get current cache status and statistics.
{
"enabled": true,
"page_cache": {
"enabled": true,
"entries": 1250,
"size": "45.2 MB"
},
"store_api_cache": {
"enabled": true,
"entries": 340
},
"last_purge": "2026-01-23T08:15:00Z"
}Purge all cache or specific cache types.
| Parameter | Type | Description |
|---|---|---|
type | string | Cache type: all, pages, store_api |
curl -X POST \
-H "X-WP-Nonce: {nonce}" \
https://example.com/wp-json/mamba/v1/purge \
-d '{"type": "all"}'{
"success": true,
"message": "Cache purged successfully",
"purged_at": "2026-01-23T10:30:00Z"
}Purge a specific URL from cache.
| Parameter | Type | Description |
|---|---|---|
url | string | URL to purge (required) |
curl -X POST \
-H "X-WP-Nonce: {nonce}" \
https://example.com/wp-json/mamba/v1/purge/url \
-d '{"url": "https://example.com/product/sample/"}'Start a cache warmup process.
| Parameter | Type | Description |
|---|---|---|
limit | int | Maximum URLs to warm |
type | string | Content type filter |
curl -X POST \
-H "X-WP-Nonce: {nonce}" \
https://example.com/wp-json/mamba/v1/warmup \
-d '{"limit": 100, "type": "products"}'{
"success": true,
"job_id": "warmup_abc123",
"urls_queued": 100,
"status": "processing"
}Get warmup job status.
{
"job_id": "warmup_abc123",
"status": "completed",
"total_urls": 100,
"processed": 100,
"successful": 98,
"failed": 2,
"duration": "45s"
}Get current Mamba settings.
{
"page_cache_enabled": true,
"store_api_cache_enabled": true,
"default_ttl": 86400,
"store_api_ttl": 300,
"cdn_enabled": false,
"warmup_enabled": true
}Update Mamba settings.
| Parameter | Type | Description |
|---|---|---|
page_cache_enabled | bool | Enable page caching |
store_api_cache_enabled | bool | Enable Store API caching |
default_ttl | int | Default TTL in seconds |
curl -X POST \
-H "X-WP-Nonce: {nonce}" \
https://example.com/wp-json/mamba/v1/settings \
-d '{"default_ttl": 43200}'Run database optimization.
| Parameter | Type | Description |
|---|---|---|
tasks | array | Tasks to run: transients, revisions, orphans |
curl -X POST \
-H "X-WP-Nonce: {nonce}" \
https://example.com/wp-json/mamba/v1/db/optimize \
-d '{"tasks": ["transients", "orphans"]}'{
"success": true,
"results": {
"transients": {"cleaned": 145},
"orphans": {"cleaned": 23}
}
}