class-litespeed-crawler.php

LiteSpeed Crawler — curl_multi variant-matrix preloader.

Source includes/Integrations/class-litespeed-crawler.php4 min readPart of Performance Optimisation

includes/Integrations/class-litespeed-crawler.php

LiteSpeed Crawler — curl_multi variant-matrix preloader.

Namespace: PerformanceOptimise\\Inc · Lines: 1160

Class LiteSpeed_Crawler

Class LiteSpeed_Crawler

Source: includes/Integrations/class-litespeed-crawler.php, line 28

final class LiteSpeed_Crawler

Tags: @since 2.0.0

Constants

ConstantVisibilityValueLine
BLACKLIST_THRESHOLDpublic338
DEFAULT_CONCURRENCYpublic246
BLACKLIST_PREFIXprivate\'wppo_crawler_blacklist_\'54
SERVER_IP_KEYprivate\'wppo_crawler_server_ip\'62
DEFERRED_BATCH_MAX_URLSpublic5070
DEFERRED_BATCH_TTLprivate2 * HOUR_IN_SECONDS78
MAX_REDIRECT_HOPSprivate593

publicstatic get_concurrency()

public static function get_concurrency(): int

Get concurrency (2-4) filtered via wppo_crawler_concurrency.

Return: int.

Tags: @since 2.0.0

Source: includes/Integrations/class-litespeed-crawler.php, line 104

publicstatic get_blacklist_threshold()

public static function get_blacklist_threshold(): int

Get blacklist threshold filtered via wppo_crawler_blacklist_threshold.

Return: int.

Tags: @since 2.0.0

Source: includes/Integrations/class-litespeed-crawler.php, line 137

publicstatic get_load_limit()

public static function get_load_limit(): float

Get load limit for throttling.

Return: float.

Tags: @since 2.0.0

Source: includes/Integrations/class-litespeed-crawler.php, line 160

publicstatic is_overloaded()

public static function is_overloaded(): bool

Whether system load is over limit (throttler).

Return: bool.

Tags: @since 2.0.0

Source: includes/Integrations/class-litespeed-crawler.php, line 208

publicstatic get_server_ip()

public static function get_server_ip(): string

Get cached server IP for CURLOPT_RESOLVE.

Return: string — IP or empty string.

Tags: @since 2.0.0

Source: includes/Integrations/class-litespeed-crawler.php, line 250

publicstatic is_blacklisted()

public static function is_blacklisted(string $url): bool

Whether URL is blacklisted (failures >= threshold).

ParameterTypeDefaultDescription
$urlstring—URL.

Return: bool.

Tags: @since 2.0.0

Source: includes/Integrations/class-litespeed-crawler.php, line 276

publicstatic record_failure()

public static function record_failure(string $url): void

Record failure for URL; increment blacklist counter.

ParameterTypeDefaultDescription
$urlstring—URL.

Return: void.

Tags: @since 2.0.0

Source: includes/Integrations/class-litespeed-crawler.php, line 289

publicstatic clear_blacklist()

public static function clear_blacklist(string $url): void

Clear blacklist for URL on success.

ParameterTypeDefaultDescription
$urlstring—URL.

Return: void.

Tags: @since 2.0.0

Source: includes/Integrations/class-litespeed-crawler.php, line 302

publicstatic build_variant_matrix()

public static function build_variant_matrix(string $url): array

Build variant matrix for a URL.

ParameterTypeDefaultDescription
$urlstring—Base URL.

Return: array<int, — array{url:string,headers:array<string,string>}>.

Tags: @since 2.0.0

Source: includes/Integrations/class-litespeed-crawler.php, line 317

publicstatic get_variants_to_warm()

public static function get_variants_to_warm(string $url): array

Get variants to warm respecting varyGroups.

ParameterTypeDefaultDescription
$urlstring—Base URL.

Return: array<int, — array{url:string,headers:array<string,string>}>.

Tags: @since 2.0.0

Source: includes/Integrations/class-litespeed-crawler.php, line 368

publicstatic get_urls_to_crawl()

public static function get_urls_to_crawl(int=500 $cap): array

Get URLs to crawl (posts + sitemap merge, 500 cap, 15s budget).

ParameterTypeDefaultDescription
$capint=500—Cap for sitemap + total URLs.

Return: string[].

Tags: @since 2.0.0

Source: includes/Integrations/class-litespeed-crawler.php, line 441

privatestatic is_url_same_host_allowed()

private static function is_url_same_host_allowed(string $url): bool

Whether a URL is allowed as a crawler target or redirect landing.

ParameterTypeDefaultDescription
$urlstring—URL to check.

Return: bool — True when the URL is allowed.

Tags: @since 2.3.0

Source: includes/Integrations/class-litespeed-crawler.php, line 640

privatestatic resolve_validated_redirect()

private static function resolve_validated_redirect(string $location, string $current_url): string|false

Resolve a redirect Location against the current URL and validate it.

ParameterTypeDefaultDescription
$locationstring—Raw Location header value.
$current_urlstring—URL of the response that sent the Location.

Return: string|false — Absolute validated URL, or false when the hop is not allowed.

Tags: @since 2.3.0

Source: includes/Integrations/class-litespeed-crawler.php, line 659

publicstatic crawl_batch()

public static function crawl_batch(array $urls, ?int=null $concurrency): array

Execute curl_multi batch for URLs (variant matrix).

ParameterTypeDefaultDescription
$urlsarray—URLs to crawl.
$concurrency?int=null—Concurrency override or null for setting.

Return: array{success:int,failed:int,skipped:int}.

Tags: @since 2.0.0

Source: includes/Integrations/class-litespeed-crawler.php, line 675

privatestatic defer_crawl_batch()

private static function defer_crawl_batch(array $urls): void

Defer a crawler batch when the server is overloaded.

ParameterTypeDefaultDescription
$urlsarray—URLs to defer.

Return: void.

Tags: @since 2.0.0

Source: includes/Integrations/class-litespeed-crawler.php, line 1007

publicstatic crawl_single()

public static function crawl_single(string $url): void

Lane wrapper for single URL preload (wraps process_url).

ParameterTypeDefaultDescription
$urlstring—URL.

Return: void.

Tags: @since 2.0.0

Source: includes/Integrations/class-litespeed-crawler.php, line 1050

publicstatic reset_cache()

public static function reset_cache(): void

Reset crawler runtime state for testing isolation.

Return: void.

Tags: @since 2.0.0

Source: includes/Integrations/class-litespeed-crawler.php, line 1138

publicstatic get_status()

public static function get_status(): array

Get crawler queue status.

Return: array{concurrency:int,load_limit:float,overloaded:bool,server_ip:string}.

Tags: @since 2.0.0

Source: includes/Integrations/class-litespeed-crawler.php, line 1151

Hooks

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

HookTypeLineNotes
wppo_crawler_concurrencyfilter114@param ×1
wppo_crawler_blacklist_thresholdfilter147@param ×1
wppo_crawler_use_nprocfilter169—
wppo_crawler_load_limitfilter196@param ×1
wppo_crawler_is_overloadedfilter238@param ×3
wppo_crawler_variantsfilter353@param ×2
wppo_crawler_full_matrixfilter374—
wppo_crawler_variantsfilter426@param ×2
wppo_crawler_sitemap_urlsfilter469@param ×2
wppo_crawler_urlsfilter499@param ×1
wppo_invalidation_urlsfilter500@param ×1
wppo_crawler_urlsfilter611@param ×1
wppo_invalidation_urlsfilter618@param ×1
wppo_crawler_disable_curlfilter749@param ×1