Skip to content

Feature: CLI cache warmup (cache:flush/clean --warmup, cache:warmup)#40637

Open
Genaker wants to merge 1 commit intomagento:2.4-developfrom
Genaker:feature/cli-cache-warmup
Open

Feature: CLI cache warmup (cache:flush/clean --warmup, cache:warmup)#40637
Genaker wants to merge 1 commit intomagento:2.4-developfrom
Genaker:feature/cli-cache-warmup

Conversation

@Genaker
Copy link
Copy Markdown
Contributor

@Genaker Genaker commented Mar 31, 2026

Fixes #40636

Description

Adds optional full-page cache warmup from the CLI after cache:flush and cache:clean, plus a standalone cache:warmup command.

  • cache:flush --warmup / -w and cache:clean --warmup / -w: after the cache operation, runs HTTP GET against configured URLs (or the storefront base URL if none configured).
  • bin/magento cache:warmup: warms caches without flushing or cleaning.
  • Admin configuration: Stores > Configuration > Advanced > Developer > CLI Cache Warmup — multiline URLs and HTTP timeout (default 30s).

Implementation: Magento\Backend\Model\Cache\WarmupRunner (reuses Magento\Framework\HTTP\Client\Curl).

Manual testing scenarios

  1. Leave Warmup URLs empty; run bin/magento cache:warmup — should GET the storefront base URL and print stage/progress and summary.
  2. Set one or more URLs; run bin/magento cache:flush --warmup — should flush, then warm each URL.
  3. Run bin/magento cache:clean -w full_page with warmup enabled — same behavior for clean.

Unit tests

  • Magento\Backend\Test\Unit\Model\Cache\WarmupRunnerTest
  • Magento\Backend\Test\Unit\Console\Command\CacheWarmupCommandTest
  • Extended CacheFlushCommandTest / CacheCleanCommandTest for --warmup

Run:
./vendor/bin/phpunit -c dev/tests/unit/phpunit.xml.dist app/code/Magento/Backend/Test/Unit/Model/Cache/WarmupRunnerTest.php app/code/Magento/Backend/Test/Unit/Console/Command/CacheWarmupCommandTest.php app/code/Magento/Backend/Test/Unit/Console/Command/CacheFlushCommandTest.php app/code/Magento/Backend/Test/Unit/Console/Command/CacheCleanCommandTest.php

- Add --warmup/-w to cache:flush and cache:clean (HTTP GET to configured URLs)
- Add bin/magento cache:warmup standalone command
- Admin: Stores > Configuration > Advanced > Developer > CLI Cache Warmup
- Unit tests for WarmupRunner and updated cache command tests
@m2-assistant
Copy link
Copy Markdown

m2-assistant bot commented Mar 31, 2026

Hi @Genaker. Thank you for your contribution!
Here are some useful tips on how you can test your changes using Magento test environment.
❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names.

Allowed build names are:
  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here
ℹ️ Run only required test builds during development. Run all test builds before sending your pull request for review.


For more details, review the Code Contributions documentation.
Join Magento Community Engineering Slack and ask your questions in #github channel.

@engcom-Hotel engcom-Hotel added feature request Priority: P2 A defect with this priority could have functionality issues which are not to expectations. labels Mar 31, 2026
@github-project-automation github-project-automation bot moved this to Pending Review in Pull Requests Dashboard Mar 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature request Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: pending review

Projects

Status: Pending Review

Development

Successfully merging this pull request may close these issues.

Feature: CLI cache warmup after cache:flush / cache:clean (optional HTTP GET)

3 participants