class-advanced-cache-handler.php

Advanced_Cache_Handler class for the PerformanceOptimise plugin.

Source includes/Cache/class-advanced-cache-handler.php3 min readPart of Performance Optimisation

includes/Cache/class-advanced-cache-handler.php

Advanced_Cache_Handler class for the PerformanceOptimise plugin.

Namespace: PerformanceOptimise\\Inc · Lines: 950

Class Advanced_Cache_Handler

Class Advanced_Cache_Handler

Source: includes/Cache/class-advanced-cache-handler.php, line 25

class Advanced_Cache_Handler

Tags: @since 1.0.0

Constants

ConstantVisibilityValueLine
DROPIN_MARKERpublic\'WPPO_ADVANCED_CACHE_DROPIN\'32

publicstatic get_dropin_path()

public static function get_dropin_path(): string

Path to the advanced-cache.php drop-in.

Return: string.

Source: includes/Cache/class-advanced-cache-handler.php, line 39

privatestatic log_dropin_issue()

private static function log_dropin_issue(string $message): void

Log a drop-in inspection problem at most once per hour.

ParameterTypeDefaultDescription
$messagestring—Message to log.

Return: void.

Tags: @since 2.0.0

Source: includes/Cache/class-advanced-cache-handler.php, line 55

publicstatic is_our_dropin()

public static function is_our_dropin(): bool

Whether the existing advanced-cache.php (if any) was created by this plugin.

Return: bool — True when the drop-in exists and is WPPO-owned; false otherwise (including unknown).

Tags: @since 1.0.0 · @since 2.0.0 Filesystem errors are logged instead of silently swallowed.

Source: includes/Cache/class-advanced-cache-handler.php, line 80

publicstatic foreign_dropin_present()

public static function foreign_dropin_present(): bool

Another plugin (or host) owns advanced-cache.php; we must not replace it.

Return: bool.

Source: includes/Cache/class-advanced-cache-handler.php, line 130

publicstatic get_dropin_backup_path()

public static function get_dropin_backup_path(): string

Path to the backup copy of our drop-in kept alongside advanced-cache.php.

Return: string — Backup file path.

Tags: @since 2.0.0

Source: includes/Cache/class-advanced-cache-handler.php, line 163

publicstatic normalize_dropin_host()

public static function normalize_dropin_host(string $raw_host): string

Normalize a raw host value the same way the generated drop-in does.

ParameterTypeDefaultDescription
$raw_hoststring—Raw host value (e.g. `$_SERVER[\’HTTP_HOST\’]`).

Return: string — Normalized lowercase host, or \’\’ when invalid.

Tags: @since 2.2.0

Source: includes/Cache/class-advanced-cache-handler.php, line 183

publicstatic is_host_allowed()

public static function is_host_allowed(string $request_host, string $canonical_host): bool

Whether a request host is allowed to read the static cache tree.

ParameterTypeDefaultDescription
$request_hoststring—Raw request host (e.g. `$_SERVER[\’HTTP_HOST\’]`).
$canonical_hoststring—Baked canonical host.

Return: bool — True when the request may read the canonical cache tree.

Tags: @since 2.2.0

Source: includes/Cache/class-advanced-cache-handler.php, line 241

publicstatic sanitize_host()

public static function sanitize_host(string $raw_host): string

Sanitize a raw host value for drop-in cache-key decisions.

ParameterTypeDefaultDescription
$raw_hoststring—Raw host value (e.g. `$_SERVER[\’HTTP_HOST\’]`).

Return: string — Normalized lowercase host, or \’\’ when invalid.

Tags: @since 2.3.0

Source: includes/Cache/class-advanced-cache-handler.php, line 266

privatestatic atomic_write_dropin()

private static function atomic_write_dropin(string $handler_code): bool

Atomically write the drop-in via tmp-plus-rename with backup and verification.

ParameterTypeDefaultDescription
$handler_codestring—Generated drop-in code.

Return: bool — True on success (or when a foreign drop-in is left untouched), false on failure.

Tags: @since 2.0.0

Source: includes/Cache/class-advanced-cache-handler.php, line 284

publicstatic create()

public static function create(): bool

Creates the advanced-cache.php file.

Return: bool — True when the drop-in is left in a correct state (regenerated, already ours, or a foreign drop-in left untouched), false on filesystem failure.

Tags: @since 1.0.0

Source: includes/Cache/class-advanced-cache-handler.php, line 435

publicstatic remove()

public static function remove(): void

Removes the advanced-cache.php file.

Return: void.

Tags: @since 1.0.0

Source: includes/Cache/class-advanced-cache-handler.php, line 861

publicstatic cleanup_stale_artifacts()

public static function cleanup_stale_artifacts(): void

Delete stale drop-in artifacts without touching the live drop-in.

Return: void.

Tags: @since 2.0.0

Source: includes/Cache/class-advanced-cache-handler.php, line 904

privatestatic cleanup_dropin_artifacts()

private static function cleanup_dropin_artifacts(): void

Delete the backup sibling and any orphaned tmp siblings.

Return: void.

Tags: @since 2.0.0

Source: includes/Cache/class-advanced-cache-handler.php, line 917