rafafortes/cache-warmer

This package is abandoned and no longer maintained. The author suggests using the rafafortes/magento2-cache-warmer package instead.

A modular Magento 2 cache warmer.

Maintainers

Package info

github.com/rafafortes/magento2-cache-warmer

pkg:composer/rafafortes/cache-warmer

Transparency log

Statistics

Installs: 3 062

Dependents: 0

Suggesters: 0

Stars: 1

Open Issues: 0

4.0.0 2026-08-20 23:14 UTC

This package is not auto-updated.

Last update: 2026-08-20 23:19:47 UTC


README

Small PHP CLI utility that requests every page listed in a sitemap. It is intended to warm Magento/Varnish caches from inside the PHP container.

Requirements

  • PHP 8.0+
  • Composer
  • ext-curl and ext-simplexml

Installation in a project

Install the package from the Magento project root:

composer require rafafortes/magento2-cache-warmer

The executable is installed by Composer at vendor/bin/magento2-cache-warmer.

Usage

vendor/bin/magento2-cache-warmer <sitemapUrl> [threads]

Example inside the PHP container:

cd /var/www/html
vendor/bin/magento2-cache-warmer \
  https://shop.test/feeds/sitemap.xml \
  5

Arguments:

  • sitemapUrl — required URL of the sitemap reachable from the PHP container. The sitemap can be a regular sitemap or a sitemap index.
  • threads — optional positive integer; number of page requests made in parallel. The default is 1.

For every sitemap and page request, the command immediately prints the URL, HTTP status, result (OK or FAIL) and elapsed time. Blocked URLs are reported as BLOCKED. It prints a final count when the run finishes.

Security rules are fail-closed: sitemap URLs must use the same HTTP(S) scheme, host and port as the sitemap, resolve to public addresses, and redirects are validated before they are followed. URLs with credentials or dangerous schemes are rejected. For a deliberately trusted local Docker host, set its exact host name explicitly:

CACHE_WARMER_TRUSTED_PRIVATE_HOSTS=shop.test \
  vendor/bin/magento2-cache-warmer https://shop.test/feeds/sitemap.xml 5

The current version deliberately does not accept a base URL, follow links found in HTML, load seed URLs, or apply a blacklist. Only URLs explicitly listed in the supplied sitemap are requested. There is no --debug option.

Library usage

use Magento2CacheWarmer\UrlFetcher;

$warmer = new UrlFetcher(
    'https://example.com/sitemap.xml',
    maxThreads: 5
);
$successfulUrls = $warmer->getFetchedUrls();
$failedUrls = $warmer->getFailedUrls();

Architecture

  • UrlFetcher is the public facade and accepts only the sitemap URL and concurrency setting.
  • Crawler loads the sitemap, expands sitemap indexes and fetches only their listed URLs.
  • CurlMultiHttpClient performs concurrent requests with TLS verification, redirects and bounded connect/total timeouts.
  • OutputInterface and ConsoleOutput provide per-request progress output.
  • HttpClientInterface allows deterministic test doubles.

Tests and quality gate

Run the tests:

composer test

Run all configured checks:

composer quality

The quality command runs PHPStan, PHPCS, PHPMD, composer audit and PHPUnit. Tests use local fakes and do not make live network requests.