class-litespeed-esi.php

LiteSpeed ESI bridge (P5).

Source includes/Integrations/class-litespeed-esi.php6 min readPart of Performance Optimisation

includes/Integrations/class-litespeed-esi.php

LiteSpeed ESI bridge (P5).

Namespace: PerformanceOptimise\\Inc · Lines: 1780

Class LiteSpeed_ESI

Class LiteSpeed_ESI

Source: includes/Integrations/class-litespeed-esi.php, line 26

final class LiteSpeed_ESI

Tags: @since 2.0.0

Properties

PropertyVisibilityTypeDefaultLine
$asset_cacheprivate staticmixednull38
$asset_cache_setprivate staticboolfalse49
$nonce_wildcard_memoprivate staticarray<string,bool>array()75

publicstatic reset_asset_cache_for_tests()

public static function reset_asset_cache_for_tests(): void

Reset the memoized asset lookup (tests / long-lived workers).

Return: void.

Tags: @since 2.2.0

Source: includes/Integrations/class-litespeed-esi.php, line 57

publicstatic is_esi_available()

public static function is_esi_available(): bool

Whether ESI is available (Enterprise only).

Return: bool.

Tags: @since 2.0.0

Source: includes/Integrations/class-litespeed-esi.php, line 85

publicstatic is_setting_enabled()

public static function is_setting_enabled(): bool

Whether the ESI bridge setting is enabled.

Return: bool.

Tags: @since 2.0.0

Source: includes/Integrations/class-litespeed-esi.php, line 130

publicstatic is_enabled()

public static function is_enabled(): bool

Whether ESI is enabled via settings AND available (Enterprise).

Return: bool.

Tags: @since 2.0.0

Source: includes/Integrations/class-litespeed-esi.php, line 148

privatestatic has_header_emitter()

private static function has_header_emitter(): bool

Whether the Header_Emitter bridge is loaded.

Return: bool — True when Header_Emitter can be called safely.

Tags: @since 2.2.0

Source: includes/Integrations/class-litespeed-esi.php, line 162

privatestatic is_fragment_throttled()

private static function is_fragment_throttled(string=\'\' $block, int=60 $limit, int=60 $window): bool

Per-IP-per-block fixed-window throttle for the public fragment endpoint.

ParameterTypeDefaultDescription
$blockstring=\'\'—Block name scoping the bucket (\’\’ for legacy callers).
$limitint=60—Max hits per window.
$windowint=60—Window in seconds.

Return: bool — True when throttled.

Tags: @since 2.2.0

Source: includes/Integrations/class-litespeed-esi.php, line 191

privatestatic has_nonce_receipt_proof()

private static function has_nonce_receipt_proof(string $nonce): bool

Whether a presented nonce value proves prior page receipt.

ParameterTypeDefaultDescription
$noncestring—The presented nonce value (may be empty).

Return: bool — True when the value is structurally a WP nonce.

Tags: @since 2.2.0

Source: includes/Integrations/class-litespeed-esi.php, line 248

privatestatic log_refresh_mint_burst()

private static function log_refresh_mint_burst(string $block): void

Log a throttled nonce-refresh burst (at most once per hour per source).

ParameterTypeDefaultDescription
$blockstring—Block name scoping the throttle bucket.

Return: void.

Tags: @since 2.3.0

Source: includes/Integrations/class-litespeed-esi.php, line 270

privatestatic emit_private_fail_closed()

private static function emit_private_fail_closed(): void

Emit the private pair, fail-closed when the emitter is unavailable.

Return: void.

Tags: @since 2.2.0

Source: includes/Integrations/class-litespeed-esi.php, line 323

privatestatic emit_nocache_fail_closed()

private static function emit_nocache_fail_closed(): void

Emit the no-cache pair, fail-closed when the emitter is unavailable.

Return: void.

Tags: @since 2.2.0

Source: includes/Integrations/class-litespeed-esi.php, line 344

privatestatic fallback_nonce_seed()

private static function fallback_nonce_seed(string $context): string

Fallback nonce seed when pluggable functions are unavailable.

ParameterTypeDefaultDescription
$contextstring—Nonce context (block name).

Return: string — MD5 seed for the fallback nonce, or \’\’ when no secret exists.

Tags: @since 2.2.0

Source: includes/Integrations/class-litespeed-esi.php, line 369

privatestatic supports_script_strategy()

private static function supports_script_strategy(): bool

Whether core supports the native `strategy` script args (WP 6.3+).

Return: bool.

Tags: @since 2.2.0

Source: includes/Integrations/class-litespeed-esi.php, line 416

publicstatic enqueue_hydration_client()

public static function enqueue_hydration_client(): void

Enqueue the ESI hydration client (build/esi.js) for OLS placeholder mode.

Return: void.

Tags: @since 2.0.0

Source: includes/Integrations/class-litespeed-esi.php, line 447

publicstatic should_punch_hole()

public static function should_punch_hole(string $context): bool

Whether a given context should punch hole via AJAX/ESI.

ParameterTypeDefaultDescription
$contextstring—Context: cart|checkout|account|adminbar|nonce etc.

Return: bool.

Tags: @since 2.0.0

Source: includes/Integrations/class-litespeed-esi.php, line 565

publicstatic render_esi_placeholder()

public static function render_esi_placeholder(string $block, array=array() $attrs): string

Render ESI placeholder.

ParameterTypeDefaultDescription
$blockstring—Block name (cart, adminbar, nonce).
$attrsarray=array()—Optional attributes.

Return: string.

Tags: @since 2.0.0

Source: includes/Integrations/class-litespeed-esi.php, line 733

privatestatic get_esi_placeholder_aria()

private static function get_esi_placeholder_aria(string $block): array

ARIA attributes for the OLS ESI placeholder.

ParameterTypeDefaultDescription
$blockstring—Block name.

Return: array<string,?string> — Attribute => value map (null skips the attribute).

Tags: @since 2.0.0

Source: includes/Integrations/class-litespeed-esi.php, line 870

publicstatic register_ajax_handlers()

public static function register_ajax_handlers(): void

Register AJAX handlers for ESI fragments.

Return: void.

Tags: @since 2.0.0

Source: includes/Integrations/class-litespeed-esi.php, line 917

publicstatic get_allowed_fragment_html()

public static function get_allowed_fragment_html(): array

Allowlist of HTML tags/attributes permitted in ESI fragment HTML.

Return: array — Allowed tags => attributes map, in wp_kses() shape.

Tags: @since 2.0.0

Source: includes/Integrations/class-litespeed-esi.php, line 936

publicstatic get_woo_fragment_guidance()

public static function get_woo_fragment_guidance(): array

WooCommerce fragment-caching guidance for dynamic commerce.

Return: array{esi_available: — string, bypass_routes: string[], fragment_blocks: string[], cookie_vary: string[], fallback: string} Structured ESI guidance.

Tags: @since 2.3.0

Source: includes/Integrations/class-litespeed-esi.php, line 1100

publicstatic render_woo_cart_fragment()

public static function render_woo_cart_fragment(): string

Render the WooCommerce cart fragment (mini-cart count + cart hash).

Return: string — Kses-safe cart fragment HTML.

Tags: @since 2.3.0

Source: includes/Integrations/class-litespeed-esi.php, line 1125

publicstatic handle_ajax_fragment()

public static function handle_ajax_fragment(): void

Handle AJAX fragment request.

Return: void.

Tags: @since 2.0.0

Source: includes/Integrations/class-litespeed-esi.php, line 1208

publicstatic inject_nonce_replacement()

public static function inject_nonce_replacement($content)

Inject nonce replacement into content.

ParameterTypeDefaultDescription
$contentmixed—Content to inject.

Return: mixed — The rewritten content, or the input unchanged.

Tags: @since 2.0.0 · @since 2.2.0 Untyped parameter and non-string passthrough, now that this runs as a live fragment filter.

Source: includes/Integrations/class-litespeed-esi.php, line 1400

publicstatic handle_send_headers()

public static function handle_send_headers(): void

Handle send_headers — emit private/no-vary for cart/checkout/account, no-cache for admin.

Return: void.

Tags: @since 2.0.0

Source: includes/Integrations/class-litespeed-esi.php, line 1474

publicstatic init()

public static function init(): void

Register ESI nonce/widget hooks.

Return: void.

Tags: @since 2.0.0

Source: includes/Integrations/class-litespeed-esi.php, line 1572

privatestatic register_nonce_injector()

private static function register_nonce_injector(): void

Attach the ESI nonce injector to the fragment-content filter.

Return: void.

Tags: @since 2.2.0

Source: includes/Integrations/class-litespeed-esi.php, line 1649

privatestatic sanitize_esi_tag_value()

private static function sanitize_esi_tag_value(string $action): string

Sanitize an ESI tag value through the canonical sanitizer when available, with a local fallback otherwise.

ParameterTypeDefaultDescription
$actionstring—Raw ESI action name.

Return: string — Sanitized tag value (max 1024 chars).

Tags: @since 2.2.0

Source: includes/Integrations/class-litespeed-esi.php, line 1669

publicstatic handle_nonce()

public static function handle_nonce($action): void

Handle litespeed_nonce action for widget/cart hole-punching.

ParameterTypeDefaultDescription
$actionstring—Nonce action.

Return: void.

Tags: @since 2.0.0

Source: includes/Integrations/class-litespeed-esi.php, line 1687

publicstatic filter_esi_nonces()

public static function filter_esi_nonces($nonces): array

Filter litespeed_esi_nonces for hole-punch list.

ParameterTypeDefaultDescription
$noncesarray—Nonce list.

Return: array.

Tags: @since 2.0.0

Source: includes/Integrations/class-litespeed-esi.php, line 1720

publicstatic ajax_fallback()

public static function ajax_fallback(string $fragment): string

AJAX fallback fragment for OLS (no ESI).

ParameterTypeDefaultDescription
$fragmentstring—Fragment HTML.

Return: string.

Tags: @since 2.0.0

Source: includes/Integrations/class-litespeed-esi.php, line 1752

Hooks

Hooks referenced in includes/Integrations/class-litespeed-esi.php:

HookTypeLineNotes
wppo_litespeed_esi_availablefilter105@param ×1
wppo_esi_availablefilter115@param ×1
wppo_esi_enabledfilter139@param ×1
wppo_esi_should_punch_holefilter590@param ×2
wppo_esi_blockfilter745@param ×2
wppo_esi_placeholderfilter815@param ×3
wppo_litespeed_esi_placeholderfilter823@param ×2
wppo_esi_placeholderfilter853@param ×3
wppo_litespeed_esi_placeholderfilter854@param ×3
wppo_esi_block_labelfilter901@param ×2
wppo_esi_allowed_htmlfilter1058@param ×1
wppo_esi_fragment_htmlfilter1345@param ×2
wppo_litespeed_esi_fragment_htmlfilter1346@param ×2
wppo_esi_nonce_contentfilter1460@param ×2
wppo_litespeed_esi_nonce_contentfilter1461@param ×2
wppo_esi_private_headers_sentaction1527@param ×1
wppo_esi_private_headers_sentaction1534—
wppo_esi_private_headers_sentaction1560—
wppo_esi_fragment_htmlfilter registration1650—
wppo_litespeed_esi_fragment_htmlfilter registration1651—
wppo_esi_noncesfilter1737@param ×1
wppo_litespeed_esi_noncesfilter1738@param ×1
wppo_esi_fallbackfilter1760@param ×2