Developer Reference

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.

mamba_cache_ttl Filter

Modify the cache TTL (time-to-live) in seconds for any cached response.

ParameterTypeDescription
$ttlintCache duration in seconds
$urlstringThe URL being cached
PHP Example
add_filter('mamba_cache_ttl', function($ttl, $url) {
    if (strpos($url, '/shop/') !== false) {
        return 1800; // 30 minutes for shop pages
    }
    return $ttl;
}, 10, 2);
Default: 86400 (24 hours)
File: src/Modules/Caching/Controller.php
mamba_default_ttl Filter

Set the default TTL for all cached pages when no specific TTL is configured.

ParameterTypeDescription
$ttlintDefault cache duration in seconds
PHP Example
add_filter('mamba_default_ttl', function($ttl) {
    return 43200; // 12 hours
}, 10, 1);
Default: 86400
File: src/Modules/Caching/Controller.php
mamba_should_cache_page Filter

Determine whether the current page should be cached. Return false to bypass caching.

ParameterTypeDescription
$should_cacheboolWhether to cache the page
PHP Example
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);
Default: true
File: src/Modules/Caching/Controller.php
mamba_cache_control_header Filter

Modify the Cache-Control header value sent with cached responses.

ParameterTypeDescription
$headerstringCache-Control header value
$ttlintCurrent TTL in seconds
PHP Example
add_filter('mamba_cache_control_header', function($header, $ttl) {
    return "public, max-age={$ttl}, stale-while-revalidate=60";
}, 10, 2);
File: src/Modules/Caching/Controller.php
mamba_stale_while_revalidate Filter

Set the stale-while-revalidate duration for cache headers.

ParameterTypeDescription
$swrintStale-while-revalidate duration in seconds
$ttlintCurrent TTL
PHP Example
add_filter('mamba_stale_while_revalidate', function($swr, $ttl) {
    return 3600; // 1 hour stale-while-revalidate
}, 10, 2);
Default: 60
File: src/Modules/Caching/Controller.php
mamba_stale_if_error Filter

Set the stale-if-error duration for cache headers.

ParameterTypeDescription
$sieintStale-if-error duration in seconds
$ttlintCurrent TTL
PHP Example
add_filter('mamba_stale_if_error', function($sie, $ttl) {
    return 86400; // Serve stale for 24h on error
}, 10, 2);
Default: 86400
File: src/Modules/Caching/Controller.php

Cache Variants

Control how cache variations are created based on cookies, headers, and query parameters.

mamba_vary_cookies Filter

Specify which cookies should create separate cache variants.

ParameterTypeDescription
$cookiesarrayArray of cookie names to vary on
PHP Example
add_filter('mamba_vary_cookies', function($cookies) {
    $cookies[] = 'my_custom_cookie';
    return $cookies;
}, 10, 1);
Default: [‘woocommerce_cart_hash’, ‘wp_woocommerce_session_*’]
File: src/Modules/Caching/Controller.php
mamba_vary_headers Filter

Specify which HTTP headers should create separate cache variants.

ParameterTypeDescription
$headersarrayArray of header names to vary on
PHP Example
add_filter('mamba_vary_headers', function($headers) {
    $headers[] = 'X-Custom-Header';
    return $headers;
}, 10, 1);
File: src/Modules/Caching/Controller.php
mamba_cache_key Filter

Modify the cache key used for storing and retrieving cached responses.

ParameterTypeDescription
$keystringThe generated cache key
$urlstringThe URL being cached
PHP Example
add_filter('mamba_cache_key', function($key, $url) {
    if (wp_is_mobile()) {
        return $key . '_mobile';
    }
    return $key;
}, 10, 2);
File: src/Modules/Caching/Controller.php
mamba_ignored_query_params Filter

Query parameters to ignore when generating cache keys (e.g., tracking parameters).

ParameterTypeDescription
$paramsarrayArray of query parameter names to ignore
PHP Example
add_filter('mamba_ignored_query_params', function($params) {
    $params[] = 'fbclid';
    $params[] = 'gclid';
    $params[] = 'utm_source';
    return $params;
}, 10, 1);
Default: Common tracking params (utm_*, fbclid, gclid, etc.)
File: src/Modules/Caching/Controller.php

Cache Invalidation

Control when and how cache is invalidated based on content changes.

mamba_purge_urls Filter

Modify the list of URLs to purge when content changes.

ParameterTypeDescription
$urlsarrayArray of URLs to purge
$post_idintThe post ID that triggered the purge
PHP Example
add_filter('mamba_purge_urls', function($urls, $post_id) {
    $urls[] = home_url('/custom-page/');
    return $urls;
}, 10, 2);
File: src/Modules/Caching/Services/Invalidation.php
mamba_purge_post_urls Filter

URLs to purge when a specific post is updated.

ParameterTypeDescription
$urlsarrayArray of URLs to purge
$postWP_PostThe post object
PHP Example
add_filter('mamba_purge_post_urls', function($urls, $post) {
    if ($post->post_type === 'product') {
        $urls[] = wc_get_page_permalink('shop');
    }
    return $urls;
}, 10, 2);
File: src/Modules/Caching/Services/Invalidation.php
mamba_cache_tags Filter

Modify cache tags assigned to a response for tag-based invalidation.

ParameterTypeDescription
$tagsarrayArray of cache tags
$urlstringThe URL being cached
PHP Example
add_filter('mamba_cache_tags', function($tags, $url) {
    if (is_product()) {
        global $product;
        $tags[] = 'product_' . $product->get_id();
    }
    return $tags;
}, 10, 2);
File: src/Modules/Caching/Controller.php
mamba_invalidation_post_types Filter

Post types that trigger cache invalidation when updated.

ParameterTypeDescription
$post_typesarrayArray of post type slugs
PHP Example
add_filter('mamba_invalidation_post_types', function($post_types) {
    $post_types[] = 'my_custom_post_type';
    return $post_types;
}, 10, 1);
Default: [‘post’, ‘page’, ‘product’]
File: src/Modules/Caching/Services/Invalidation.php

Store API Caching

Control caching behavior for WooCommerce Store API endpoints.

mamba_store_api_cache_enabled Filter

Enable or disable Store API caching globally.

ParameterTypeDescription
$enabledboolWhether Store API caching is enabled
PHP Example
add_filter('mamba_store_api_cache_enabled', '__return_false');
Default: true
File: src/Modules/Caching/Services/StoreAPI.php
mamba_store_api_ttl Filter

Set the TTL for Store API responses.

ParameterTypeDescription
$ttlintCache duration in seconds
$routestringThe API route being cached
PHP Example
add_filter('mamba_store_api_ttl', function($ttl, $route) {
    if (strpos($route, '/products') !== false) {
        return 3600; // 1 hour for products
    }
    return $ttl;
}, 10, 2);
Default: 300 (5 minutes)
File: src/Modules/Caching/Services/StoreAPI.php
mamba_store_api_cacheable_routes Filter

Define which Store API routes are cacheable.

ParameterTypeDescription
$routesarrayArray of cacheable route patterns
PHP Example
add_filter('mamba_store_api_cacheable_routes', function($routes) {
    $routes[] = '/wc/store/v1/custom-endpoint';
    return $routes;
}, 10, 1);
Default: [‘/wc/store/v1/products’, ‘/wc/store/v1/cart’]
File: src/Modules/Caching/Services/StoreAPI.php
mamba_store_api_excluded_routes Filter

Routes to exclude from Store API caching.

ParameterTypeDescription
$routesarrayArray of route patterns to exclude
PHP Example
add_filter('mamba_store_api_excluded_routes', function($routes) {
    $routes[] = '/wc/store/v1/checkout';
    return $routes;
}, 10, 1);
File: src/Modules/Caching/Services/StoreAPI.php
mamba_store_api_vary_headers Filter

Headers to vary Store API cache on.

ParameterTypeDescription
$headersarrayArray of header names
PHP Example
add_filter('mamba_store_api_vary_headers', function($headers) {
    $headers[] = 'X-Customer-Group';
    return $headers;
}, 10, 1);
File: src/Modules/Caching/Services/StoreAPI.php

Warmup & Preloading

Control cache warming behavior and URL discovery.

mamba_warmup_urls Filter

Modify the list of URLs to warm up.

ParameterTypeDescription
$urlsarrayArray of URLs to warm
PHP Example
add_filter('mamba_warmup_urls', function($urls) {
    $urls[] = home_url('/important-landing-page/');
    return $urls;
}, 10, 1);
File: src/Modules/Caching/Services/Preload/Warmup/Warmer.php
mamba_warmup_batch_size Filter

Number of URLs to warm per batch.

ParameterTypeDescription
$sizeintBatch size
PHP Example
add_filter('mamba_warmup_batch_size', function($size) {
    return 20; // Process 20 URLs per batch
}, 10, 1);
Default: 10
File: src/Modules/Caching/Services/Preload/Warmup/Warmer.php
mamba_warmup_concurrency Filter

Number of concurrent warmup requests.

ParameterTypeDescription
$concurrencyintNumber of concurrent requests
PHP Example
add_filter('mamba_warmup_concurrency', function($concurrency) {
    return 5; // 5 concurrent requests
}, 10, 1);
Default: 3
File: src/Modules/Caching/Services/Preload/Warmup/Warmer.php
mamba_warmup_delay Filter

Delay between warmup batches in milliseconds.

ParameterTypeDescription
$delayintDelay in milliseconds
PHP Example
add_filter('mamba_warmup_delay', function($delay) {
    return 500; // 500ms between batches
}, 10, 1);
Default: 100
File: src/Modules/Caching/Services/Preload/Warmup/Warmer.php
mamba_warmup_timeout Filter

Timeout for warmup requests in seconds.

ParameterTypeDescription
$timeoutintTimeout in seconds
PHP Example
add_filter('mamba_warmup_timeout', function($timeout) {
    return 30; // 30 second timeout
}, 10, 1);
Default: 10
File: src/Modules/Caching/Services/Preload/Warmup/Warmer.php
mamba_warmup_post_types Filter

Post types to include in warmup URL discovery.

ParameterTypeDescription
$post_typesarrayArray of post type slugs
PHP Example
add_filter('mamba_warmup_post_types', function($post_types) {
    $post_types[] = 'portfolio';
    return $post_types;
}, 10, 1);
Default: [‘post’, ‘page’, ‘product’]
File: src/Modules/Caching/Services/Preload/Warmup/Warmer.php

CDN Integration

Configure CDN behavior and cache tag management.

mamba_cdn_enabled Filter

Enable or disable CDN integration.

ParameterTypeDescription
$enabledboolWhether CDN is enabled
PHP Example
add_filter('mamba_cdn_enabled', function($enabled) {
    return !is_admin(); // Only enable CDN on frontend
}, 10, 1);
File: src/Modules/CDN/Controller.php
mamba_cdn_url Filter

Modify the CDN URL used for assets.

ParameterTypeDescription
$cdn_urlstringThe CDN base URL
PHP Example
add_filter('mamba_cdn_url', function($cdn_url) {
    return 'https://cdn.example.com';
}, 10, 1);
File: src/Modules/CDN/Controller.php
mamba_cdn_cache_tags Filter

Modify CDN cache tags for tag-based purging.

ParameterTypeDescription
$tagsarrayArray of cache tags
PHP Example
add_filter('mamba_cdn_cache_tags', function($tags) {
    $tags[] = 'custom_tag_' . get_current_blog_id();
    return $tags;
}, 10, 1);
File: src/Modules/CDN/Controller.php
mamba_cdn_excluded_extensions Filter

File extensions to exclude from CDN rewriting.

ParameterTypeDescription
$extensionsarrayArray of file extensions
PHP Example
add_filter('mamba_cdn_excluded_extensions', function($extensions) {
    $extensions[] = 'pdf';
    return $extensions;
}, 10, 1);
File: src/Modules/CDN/Controller.php

Media & LCP Optimization

Control image optimization and Largest Contentful Paint detection.

mamba_lcp_enabled Filter

Enable or disable LCP optimization.

ParameterTypeDescription
$enabledboolWhether LCP optimization is enabled
PHP Example
add_filter('mamba_lcp_enabled', '__return_true');
File: src/Modules/Media/Controller.php
mamba_lcp_image Filter

Override the detected LCP image for a page.

ParameterTypeDescription
$image_urlstringThe LCP image URL
$urlstringThe page URL
PHP Example
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);
File: src/Modules/Media/Controller.php
mamba_lazy_load_enabled Filter

Enable or disable lazy loading for images.

ParameterTypeDescription
$enabledboolWhether lazy loading is enabled
PHP Example
add_filter('mamba_lazy_load_enabled', function($enabled) {
    return !is_product(); // Disable on product pages
}, 10, 1);
File: src/Modules/Media/Controller.php
mamba_lazy_load_threshold Filter

Set the lazy load threshold (distance from viewport).

ParameterTypeDescription
$thresholdstringThreshold value (e.g., ‘200px’)
PHP Example
add_filter('mamba_lazy_load_threshold', function($threshold) {
    return '300px';
}, 10, 1);
Default: 200px
File: src/Modules/Media/Controller.php

DNS Prefetch & Preconnect

Control DNS prefetching and preconnect hints.

mamba_dns_prefetch_urls Filter

URLs to add DNS prefetch hints for.

ParameterTypeDescription
$urlsarrayArray of URLs to prefetch
PHP Example
add_filter('mamba_dns_prefetch_urls', function($urls) {
    $urls[] = 'https://api.example.com';
    return $urls;
}, 10, 1);
File: src/Modules/DNS/Controller.php
mamba_preconnect_urls Filter

URLs to add preconnect hints for.

ParameterTypeDescription
$urlsarrayArray of URLs to preconnect
PHP Example
add_filter('mamba_preconnect_urls', function($urls) {
    $urls[] = ['url' => 'https://fonts.googleapis.com', 'crossorigin' => true];
    return $urls;
}, 10, 1);
File: src/Modules/DNS/Controller.php

Database Optimization

Control database cleanup and optimization tasks.

mamba_db_cleanup_enabled Filter

Enable or disable automatic database cleanup.

ParameterTypeDescription
$enabledboolWhether cleanup is enabled
PHP Example
add_filter('mamba_db_cleanup_enabled', '__return_false');
File: src/Modules/DB/Services/DatabaseOptimizer.php
mamba_db_cleanup_tasks Filter

Modify the list of database cleanup tasks.

ParameterTypeDescription
$tasksarrayArray of cleanup task identifiers
PHP Example
add_filter('mamba_db_cleanup_tasks', function($tasks) {
    unset($tasks['revisions']); // Keep revisions
    return $tasks;
}, 10, 1);
File: src/Modules/DB/Services/DatabaseOptimizer.php
mamba_db_transient_expiry Filter

Age threshold for cleaning expired transients.

ParameterTypeDescription
$daysintDays before transients are cleaned
PHP Example
add_filter('mamba_db_transient_expiry', function($days) {
    return 7; // Clean transients older than 7 days
}, 10, 1);
Default: 1
File: src/Modules/DB/Services/DatabaseOptimizer.php

Admin & Permissions

Control admin interface and user permissions.

mamba_admin_capability Filter

Required capability to access Mamba admin pages.

ParameterTypeDescription
$capabilitystringWordPress capability
PHP Example
add_filter('mamba_admin_capability', function($capability) {
    return 'manage_woocommerce'; // Allow shop managers
}, 10, 1);
Default: manage_options
File: src/Settings/AdminPage.php
mamba_purge_capability Filter

Required capability to purge cache.

ParameterTypeDescription
$capabilitystringWordPress capability
PHP Example
add_filter('mamba_purge_capability', function($capability) {
    return 'edit_posts'; // Allow editors to purge
}, 10, 1);
Default: manage_options
File: src/Settings/AdminPage.php
mamba_admin_bar_enabled Filter

Show or hide Mamba in the admin bar.

ParameterTypeDescription
$enabledboolWhether to show admin bar item
PHP Example
add_filter('mamba_admin_bar_enabled', '__return_false');
Default: true
File: src/Settings/AdminPage.php

Action Hooks

Hook into Mamba events for custom integrations.

mamba_purge_tags Action

Triggered when purging by CDN tags.

ParameterTypeDescription
$tagsarrayArray of cache tags being purged
PHP Example
add_action('mamba_purge_tags', function($tags) {
    error_log('Mamba purged tags: ' . implode(', ', $tags));
}, 10, 1);
File: src/Modules/Caching/Services/Invalidation.php
mamba_purge_urls Action

Triggered when purging specific URLs.

ParameterTypeDescription
$urlsarrayArray of URLs being purged
$headerCombosarrayHeader combinations (optional)
PHP Example
add_action('mamba_purge_urls', function($urls, $headerCombos = []) {
    foreach ($urls as $url) {
        error_log('Mamba purged URL: ' . $url);
    }
}, 10, 2);
File: src/Modules/Caching/Services/Invalidation.php
mamba_cache_purged Action

Triggered after the full cache has been purged.

PHP Example
add_action('mamba_cache_purged', function() {
    error_log('Mamba cache was fully purged');
});
File: src/Modules/Caching/Services/Invalidation.php
mamba_purge_all Action

Triggered when a full cache purge is performed.

PHP Example
add_action('mamba_purge_all', function() {
    // Notify external systems of full cache clear
});
File: src/Modules/Caching/Services/Invalidation.php
mamba_store_api_cleared Action

Triggered when the Store API cache is cleared.

PHP Example
add_action('mamba_store_api_cleared', function() {
    error_log('Mamba Store API cache was cleared');
});
File: src/Modules/Caching/Services/Invalidation.php
mamba_db_task_completed Action

Triggered when a database optimization task completes.

ParameterTypeDescription
$taskIdstringTask identifier
$affectedintNumber of rows affected
PHP Example
add_action('mamba_db_task_completed', function($taskId, $affected) {
    error_log("Mamba DB task {$taskId}: {$affected} rows affected");
}, 10, 2);
File: src/Modules/DB/Services/DatabaseOptimizer.php
mamba_cache_error Action

Triggered when a cache-related error occurs.

ParameterTypeDescription
$messagestringError message
$contextarrayAdditional context
PHP Example
add_action('mamba_cache_error', function($message, $context = []) {
    error_log('Mamba error: ' . $message);
}, 10, 2);
File: src/Modules/DB/Services/DatabaseOptimizer.php

WP-CLI Commands

Manage Mamba cache from the command line.

wp mamba purge CLI

Purge all cached pages and Store API responses.

OptionDescription
--store-apiOnly purge Store API cache
--pagesOnly purge page cache
Terminal
# Purge all cache
wp mamba purge

# Purge only Store API cache
wp mamba purge --store-api

# Purge only page cache
wp mamba purge --pages
wp mamba purge url CLI

Purge a specific URL from cache.

ArgumentDescription
<url>The URL to purge (required)
Terminal
wp mamba purge url https://example.com/shop/
wp mamba warmup CLI

Warm up the cache by pre-fetching URLs.

OptionDescription
--limit=<n>Maximum URLs to warm (default: all)
--type=<type>Content type: posts, products, categories
--concurrency=<n>Concurrent requests (default: 3)
Terminal
# 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=5
wp mamba status CLI

Display cache status and statistics.

OptionDescription
--format=<format>Output format: table, json, csv
Terminal
# Display status table
wp mamba status

# Get JSON output
wp mamba status --format=json
wp mamba db optimize CLI

Run database optimization tasks.

OptionDescription
--task=<task>Specific task: transients, revisions, orphans
--dry-runPreview changes without executing
Terminal
# 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=revisions
wp mamba config CLI

View or modify Mamba configuration.

SubcommandDescription
get <key>Get a configuration value
set <key> <value>Set a configuration value
listList all configuration
Terminal
# 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 43200

REST API Endpoints

Programmatically manage cache via REST API. All endpoints require authentication with manage_options capability.

GET /wp-json/mamba/v1/status GET

Get current cache status and statistics.

Response
{
  "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"
}
POST /wp-json/mamba/v1/purge POST

Purge all cache or specific cache types.

ParameterTypeDescription
typestringCache type: all, pages, store_api
Request
curl -X POST \
  -H "X-WP-Nonce: {nonce}" \
  https://example.com/wp-json/mamba/v1/purge \
  -d '{"type": "all"}'
Response
{
  "success": true,
  "message": "Cache purged successfully",
  "purged_at": "2026-01-23T10:30:00Z"
}
POST /wp-json/mamba/v1/purge/url POST

Purge a specific URL from cache.

ParameterTypeDescription
urlstringURL to purge (required)
Request
curl -X POST \
  -H "X-WP-Nonce: {nonce}" \
  https://example.com/wp-json/mamba/v1/purge/url \
  -d '{"url": "https://example.com/product/sample/"}'
POST /wp-json/mamba/v1/warmup POST

Start a cache warmup process.

ParameterTypeDescription
limitintMaximum URLs to warm
typestringContent type filter
Request
curl -X POST \
  -H "X-WP-Nonce: {nonce}" \
  https://example.com/wp-json/mamba/v1/warmup \
  -d '{"limit": 100, "type": "products"}'
Response
{
  "success": true,
  "job_id": "warmup_abc123",
  "urls_queued": 100,
  "status": "processing"
}
GET /wp-json/mamba/v1/warmup/{job_id} GET

Get warmup job status.

Response
{
  "job_id": "warmup_abc123",
  "status": "completed",
  "total_urls": 100,
  "processed": 100,
  "successful": 98,
  "failed": 2,
  "duration": "45s"
}
GET /wp-json/mamba/v1/settings GET

Get current Mamba settings.

Response
{
  "page_cache_enabled": true,
  "store_api_cache_enabled": true,
  "default_ttl": 86400,
  "store_api_ttl": 300,
  "cdn_enabled": false,
  "warmup_enabled": true
}
POST /wp-json/mamba/v1/settings POST

Update Mamba settings.

ParameterTypeDescription
page_cache_enabledboolEnable page caching
store_api_cache_enabledboolEnable Store API caching
default_ttlintDefault TTL in seconds
Request
curl -X POST \
  -H "X-WP-Nonce: {nonce}" \
  https://example.com/wp-json/mamba/v1/settings \
  -d '{"default_ttl": 43200}'
POST /wp-json/mamba/v1/db/optimize POST

Run database optimization.

ParameterTypeDescription
tasksarrayTasks to run: transients, revisions, orphans
Request
curl -X POST \
  -H "X-WP-Nonce: {nonce}" \
  https://example.com/wp-json/mamba/v1/db/optimize \
  -d '{"tasks": ["transients", "orphans"]}'
Response
{
  "success": true,
  "results": {
    "transients": {"cleaned": 145},
    "orphans": {"cleaned": 23}
  }
}

Mamba Caching for WooCommerce Reference • Last updated: January 2026

Generated from codebase analysis