class-header-emitter.php

Header emitter — single consolidation point for dynamic header() emission.

Source includes/Edge/class-header-emitter.php2 min readPart of Performance Optimisation

includes/Edge/class-header-emitter.php

Header emitter — single consolidation point for dynamic header() emission.

Namespace: PerformanceOptimise\\Inc · Lines: 182

Class Header_Emitter

Class Header_Emitter

Source: includes/Edge/class-header-emitter.php, line 28

final class Header_Emitter

Tags: @since 2.0.0

publicstatic strip_crlf()

public static function strip_crlf(string $value): string

Strip CR/LF (and NUL) bytes from a value before it is passed to header().

ParameterTypeDefaultDescription
$valuestring—Header value to clean.

Return: string — Value without header-breaking control characters.

Tags: @since 2.0.0

Source: includes/Edge/class-header-emitter.php, line 41

publicstatic emit()

public static function emit(string $header, bool=true $replace): bool

Emit a single header line (CRLF-safe, headers_sent-guarded).

ParameterTypeDefaultDescription
$headerstring—Full header line (e.g. \’X-LiteSpeed-Tag: WPPO\’).
$replacebool=true—Whether to replace a previous similar header.

Return: bool — True when emitted, false when headers were already sent.

Tags: @since 2.0.0

Source: includes/Edge/class-header-emitter.php, line 56

publicstatic emit_private_pair()

public static function emit_private_pair(): void

Emit the ESI private pair (Cache-Control + X-LiteSpeed-Cache-Control).

Return: void.

Tags: @since 2.0.0

Source: includes/Edge/class-header-emitter.php, line 79

publicstatic emit_nocache_pair()

public static function emit_nocache_pair(): void

Emit the ESI no-cache pair (Cache-Control + X-LiteSpeed-Cache-Control).

Return: void.

Tags: @since 2.0.0

Source: includes/Edge/class-header-emitter.php, line 98

publicstatic emit_purge_tag()

public static function emit_purge_tag(string $tag_str): bool

Emit an X-LiteSpeed-Purge tag header (CRLF-safe).

ParameterTypeDefaultDescription
$tag_strstring—Comma-separated tag list (unsanitized).

Return: bool — True when emitted, false when headers were already sent.

Tags: @since 2.0.0

Source: includes/Edge/class-header-emitter.php, line 113

publicstatic emit_tag()

public static function emit_tag(string $tag): bool

Emit an X-LiteSpeed-Tag header (CRLF-safe).

ParameterTypeDefaultDescription
$tagstring—Single tag value (unsanitized).

Return: bool — True when emitted, false when headers were already sent.

Tags: @since 2.0.0

Source: includes/Edge/class-header-emitter.php, line 124

publicstatic emit_esi_tag()

public static function emit_esi_tag(string $action): bool

Emit an ESI tag header (X-LiteSpeed-Tag: ESI.{action}).

ParameterTypeDefaultDescription
$actionstring—ESI action name (unsanitized).

Return: bool — True when emitted, false when headers were already sent.

Tags: @since 2.0.0

Source: includes/Edge/class-header-emitter.php, line 135

publicstatic remove_generic_cache_control()

public static function remove_generic_cache_control(): void

Remove generic Cache-Control/Pragma when the LiteSpeed public header is sent.

Return: void.

Tags: @since 2.0.0

Source: includes/Edge/class-header-emitter.php, line 148

publicstatic sanitize_tag()

public static function sanitize_tag(string $tag): string

Allowlist a LiteSpeed tag value to the safe header charset.

ParameterTypeDefaultDescription
$tagstring—Raw tag value.

Return: string — Sanitized tag value.

Tags: @since 2.2.0

Source: includes/Edge/class-header-emitter.php, line 172