Page Caching

mamba_cache_honor_client_no_cache
Honor Cache-Control: no-cache requests to bypass the page cache. This is particularly useful for development and debugging.

add_filter('mamba_cache_honor_client_no_cache', function () {
    return defined('WP_DEBUG') && WP_DEBUG;
});

mamba_cache_block_on_cookies
Specify cookie names or prefixes that should disable full-page caching when present and non-empty. This ensures safe handling of personalized content.

add_filter('mamba_cache_block_on_cookies', function ($cookies) {
    $cookies[] = 'my_personalization_cookie';
    return $cookies;
});

mamba_cache_stale_lock_window
Control how long (in seconds) stale content may be served while a regeneration lock is active.

add_filter('mamba_cache_stale_lock_window', fn() => 60);

mamba_cache_default_cache_control
Override the default Cache-Control header when none is provided by the origin.

add_filter('mamba_cache_default_cache_control', function () {
    return 'public, max-age=300, s-maxage=7200, stale-while-revalidate=60, stale-if-error=86400';
});

mamba_cache_vary
Adjust the list of Vary headers applied to responses and persisted in cached entries.

add_filter('mamba_cache_vary', function ($vary) {
    // Keep lean for better edge HITs
    return ['Accept-Language', 'Accept-Encoding'];
});

mamba_cache_send_content_length_on_hit
Decide whether to send a Content-Length header on cache HITs. Only safe when no compression handlers are active.

add_filter('mamba_cache_send_content_length_on_hit', '__return_true');

mamba_cache_header_whitelist
Define which response headers are persisted and re-emitted on cache HITs.

add_filter('mamba_cache_header_whitelist', function ($headers) {
    $headers[] = 'X-Custom-Security';
    return $headers;
});

mamba_cache_size_limit
Set the maximum on-disk cache size (in bytes). Safe minimum and maximum bounds are enforced.

add_filter('mamba_cache_size_limit', fn($bytes) => 512 * 1024 * 1024); // 512MB

Copyright 2025 - Mamba


Mamba mascot