WP Manifestindependent plugin directory
manifest / performance / lh-cache-warmer

LH Cache Warmer

Warms the LiteSpeed cache after a purge by fetching recent posts, menu items, and paginated front page URLs.

★ 0stars

Install

Download source zip No release zip yet

This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.

Install straight from GitHub with WP-CLI:

wp plugin install https://github.com/lhero-org/lh-cache-warmer/archive/refs/heads/main.zip
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.

Warms the LiteSpeed cache after a purge by fetching a scoped set of URLs on the current site. Designed for WordPress Multisite as part of the LocalHero platform.


Description

After a LiteSpeed cache purge, this plugin automatically schedules a background cron job that visits a curated set of URLs as an unauthenticated visitor, ensuring those pages are cached before real users arrive.

The URL set is intentionally scoped to high-value content:

  • The front page and its first 5 paginated archive pages (/page/2/ etc.)
  • The 20 most recent published posts
  • All published pages
  • URLs from administrator-configured navigation menus

Password-protected posts and pages are excluded. Admin URLs and external URLs found in menus are excluded. Menu items restricted to logged-in users are excluded automatically at warm time (cron runs as user ID 0).


Installation

  1. Upload the lh-cache-warmer folder to /wp-content/plugins/
  2. Activate the plugin on each site where cache warming is desired (not network-activated)
  3. Go to Settings > Cache Warmer and configure the menus to include

Admin Interface

Settings > Cache Warmer

Menus to Warm A list of all registered navigation menus shown as checkboxes. Check any menus whose public-facing URLs should be included in the warm cycle. Only URLs on the current site are included; admin URLs and external links are excluded automatically.

Delay Between Requests (ms) Milliseconds to pause between each outbound request during the warm cycle. Default: 500. Reduce to 200–300ms if warming is too slow; increase if the server shows load spikes during warming.

Manual Warm Triggers a warm cycle immediately (scheduled 1 second from now via WP-Cron). Only shown when no warm cycle is already pending.

URLs to be Warmed A live preview of the deduplicated URL list that will be warmed, with the post/page title, a link to the front-end URL, and an Edit link for posts and pages. Count is shown at the top.

Note: Menu URLs shown here reflect the current admin view. Items restricted to logged-in users will be excluded automatically during the warm cycle.


How It Works

  1. LiteSpeed Cache fires litespeed_purged_all or litespeed_purged_front on a full purge
  2. The plugin checks whether a warm cycle is already pending via wp_next_scheduled()
  3. If not, it schedules a single wp_schedule_single_event() 30 seconds in the future
  4. When the cron fires, it calls get_url_items() to build the URL list, deduplicates, then fetches each URL sequentially via wp_remote_get() with the configured delay between requests
  5. The next purge will schedule a fresh cycle

The 30-second delay allows rapid successive purges to settle before warming begins, preventing redundant warm cycles.


Database

This plugin creates no database tables. Settings are stored per-site using get_option() / update_option() under the key lh_cache_warmer_settings.


Constants

None.


Hooks

Actions

Hook Description
litespeed_purged_all Triggers a warm cycle schedule
litespeed_purged_front Triggers a warm cycle schedule
lh_cache_warmer_run The cron hook that executes the warm cycle

Options

Option key Scope Description
lh_cache_warmer_settings Per-site Array containing menu_slugs (array of slugs) and delay_ms (int)

Cron Jobs

Hook Type Description
lh_cache_warmer_run Single event, scheduled on purge Fetches all warm URLs sequentially

Changelog

1.0.1 — 2026-06-07

  • Exclude password-protected posts and pages from warm cycle
  • Exclude admin URLs from menu items
  • Add edit links to URL list on settings page
  • Add notice about menu URL discrepancy between admin view and warm cycle
  • Add readme.md and index.php directory guards

1.0.0 — 2026-06-07

  • Initial release
  • Warms front page (pages 1–5), recent posts (last 20), all pages, and configured menu URLs
  • Excludes password-protected content, admin URLs, and external URLs
  • Settings page with checkbox menu selection, delay configuration, live URL preview, and manual warm trigger
  • Deduplicates URLs within each warm cycle
  • Skips scheduling if a warm cycle is already pending