framecreative/wp-rocket-preload-sitemap

Limits preloading of WP Rocket cache pages to things in the sitemap - works off Yoast SEO sitemap by default.

Maintainers

Package info

github.com/framecreative/wp-rocket-preload-sitemap

Homepage

Type:wordpress-plugin

pkg:composer/framecreative/wp-rocket-preload-sitemap

Transparency log

Statistics

Installs: 6

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-07-20 04:06 UTC

This package is auto-updated.

Last update: 2026-07-20 07:46:53 UTC


README

Restricts WP Rocket's preload feature to the URLs found in a single sitemap. Any URL not present in the sitemap is excluded from preloading — it will still be cached normally when a visitor hits it, it just won't be warmed in advance.

Based on WP Rocket's official helper plugin samples, adapted for Frame Creative sites.

Requirements

  • PHP 8.1+
  • WP Rocket (active, with preload enabled)
  • Yoast SEO (optional — used for sitemap auto-detection)

Installation

Released on Packagist only, installed via Composer:

composer require framecreative/wp-rocket-preload-sitemap

The package type is wordpress-plugin, so composer/installers will place it in wp-content/plugins/. Activate it from the WordPress admin as usual.

How the sitemap URL is chosen

The sitemap URL is resolved lazily (when WP Rocket's preload actually runs, not at plugin load), so it doesn't depend on plugin load order. Resolution order:

  1. WPR_HELPER_CUSTOM_SITEMAP_URL constant — if pre-defined, wins over everything.
  2. FC_SITEMAP_URL constant — define it in wp-config.php to point at any sitemap:
    define( 'FC_SITEMAP_URL', 'https://example.com/custom-sitemap.xml' );
  3. Yoast SEO — if Yoast is active, its sitemap_index.xml URL is used automatically.
  4. Fallback{home_url}/sitemap_index.xml.

How it works

  • Filters rocket_sitemap_preload_list so WP Rocket's preload crawler only reads the chosen sitemap.
  • Filters rocket_preload_exclude_urls so any URL not present in the sitemap is excluded from the preload table.
  • Attachment URLs are never preloaded, regardless of sitemap state. Detection covers ?attachment_id= permalinks, direct files under /wp-content/uploads/, and pretty attachment pages (matched by attachment slug lookup).
  • The parsed list of sitemap URLs is cached in the rocket_custom_sitemap_links transient for 24 hours. Delete that transient to force a re-fetch after changing the sitemap.
  • If the sitemap can't be fetched (or comes back empty), nothing else is excluded — better to preload too much than to empty the preload table over a transient error. Failures are cached for 5 minutes so a broken sitemap doesn't trigger a fetch for every URL WP Rocket evaluates.

On activation

To make the sitemap change take effect immediately, activation will:

  1. Clear the cached sitemap URL list
  2. Truncate WP Rocket's preload table ({prefix}wpr_rocket_cache), if it exists
  3. Clear the WP Rocket cache for the domain
  4. Toggle the preload setting off and on to restart the preload

On deactivation

The cached sitemap URL list is cleared and the preload setting is toggled off and on again, so WP Rocket rebuilds its preload list without the sitemap restriction.

Both hooks only touch WP Rocket settings when WP Rocket is active, and never force-enable a preload that was switched off.

License

GPL-2.0-or-later