Download the PHP package blackbird/module-cache-warmer without Composer
On this page you can find all versions of the php package blackbird/module-cache-warmer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download blackbird/module-cache-warmer
More information about blackbird/module-cache-warmer
Files in blackbird/module-cache-warmer
Package module-cache-warmer
Short Description A Magento 2 module that improves store performance by automatically warming cache through intelligent page crawling and async refresh mechanisms.
License MIT
Informations about the package module-cache-warmer
Blackbird Cache Warmer
This module provides functionality to warm up the cache by crawling pages of your Magento store. It helps improve the performance of your store by ensuring that cache is pre-populated, resulting in faster page load times for your customers.
Key functionality includes:
- Crawling pages of your Magento store to warm up the cache
- Configuring basic authentication for crawling
- Setting concurrency for crawling
- Enabling/disabling store switching
- Configuring customer credentials for authenticated crawling
- Automatic async cache refresh for entities (products, categories, CMS pages, etc.)
- Automatic cache warming when full_page cache is flushed from the admin panel
- Slack webhook notifications for cache warming errors
The source code is available at the GitHub repository.
Setup
Get the Package
Zip Package:
Unzip the package into app/code/Blackbird/CacheWarmer
, from the root of your Magento instance.
Composer Package:
Install the Module
Go to your Magento root directory, then run the following Magento commands:
If you are in production mode, do not forget to recompile and redeploy the static resources, or to use the --keep-generated
option.
Features
Cache Warming
The Cache Warmer module crawls pages of your Magento store to warm up the cache. This helps improve the performance of your store by ensuring that cache is pre-populated, resulting in faster page load times for your customers.
Configurable Crawling
The module provides various configuration options for crawling:
- Basic authentication for crawling
- Concurrency for crawling (number of concurrent requests)
- Store switching (enable/disable)
- Customer credentials for authenticated crawling
- Crawling for not logged in users (enable/disable)
- Default collector type (Sitemap or Product)
Automatic Async Cache Refresh for Entities
The module includes a feature that automatically triggers an asynchronous cache refresh for entities (products, categories, CMS pages) when their Varnish cache is cleaned. This ensures that entity pages are quickly re-cached after cache invalidation, maintaining optimal performance for your store.
How it works:
- When an entity's cache is invalidated in Varnish (through the \Magento\CacheInvalidate\Observer\InvalidateVarnishObserver), the module detects this and adds the entity to a queue.
- A cron job runs every minute to process the queue and warm the cache for these entities.
- The queue is stored in a dedicated database table (
blackbird_cachewarmer_entity_queue
), ensuring reliability and persistence.
Supported Entity Types:
- Products
- Categories
- CMS Pages
Automatic Cache Warming on Full Page Cache Flush
The module includes a feature that automatically triggers cache warming when the full_page cache is flushed from the admin panel. This ensures that your store's pages are quickly re-cached after a cache flush, maintaining optimal performance.
How it works:
- When the full_page cache is flushed from the admin panel (either through "Flush Magento Cache" or "Flush Cache Storage"), the module detects this event.
- The module sets a flag in the database to indicate that cache warming should be triggered.
- A cron job runs every minute to check if cache warming should be triggered.
- If cache warming is triggered, the cron job warms the cache for all urls as the command does.
- The module uses a timestamp-based flag system to:
- Ensure that only one cache warming process runs at a time
- Automatically kill any process that has been running for more than 6 hours
Custom Logging
The module provides custom logging to warmer.log
with configurable log levels. You can select the log level for warmer.log
(default: error). Messages with this level and higher will be logged to var/log/warmer.log
.
Slack Webhook Notifications
The module can send notifications to Slack when cache warming encounters errors. This helps administrators monitor the cache warming process and quickly identify and resolve issues.
How it works:
- When cache warming encounters errors, the module sends a notification to the configured Slack webhook URL.
- The notification includes a message indicating that errors occurred and advises checking the logs for more details.
- This feature can be enabled/disabled in the module configuration.
Usage
Configuration
The module can be configured in the Magento admin panel under Stores > Configuration > Blackbird Extensions > Cache Warmer.
General Configuration
- Basic Auth Username: Username for basic authentication
- Basic Auth Password: Password for basic authentication
- Concurrency: Number of concurrent requests (default: 1)
- Switch Store: Enable/disable store switching (default: disabled)
- Instances: Instances configuration
- Customer Credentials: Customer credentials for authentication (format: username:password)
- Disable Not Logged In Crawl: Enable/disable crawling for not logged in users (default: disabled)
- Default Collector Type: Select the default collector type (Sitemap or Product) or leave empty for no default
- Enable Slack Webhook Notifications: Enable/disable notifications to Slack when cache warming encounters errors (default: disabled)
- Slack Webhook URL: URL of the Slack webhook to send notifications to
Logging Configuration
- Log Level: Select the log level for warmer.log (default: error). Messages with this level and higher will be logged to var/log/warmer.log
Console Commands
The module provides console commands to run the cache warmer:
Extending with Custom Collector Types
The module provides an extensible architecture that allows third-party modules to add their own collector types. To add a custom collector type, follow these steps:
-
Create a class that implements
Blackbird\CacheWarmer\Api\UrlCollectorInterface
: -
Create a provider class that implements
Blackbird\CacheWarmer\Api\CollectorTypeProviderInterface
: - Register your provider in your module's
di.xml
:
Extending with Custom Entity Types
The module provides an extensible architecture that allows third-party modules to add support for additional entity types. To add support for a custom entity type, follow these steps:
-
Create a class that implements
Blackbird\CacheWarmer\Api\EntityUrlProviderInterface
: - Register your provider in your module's
di.xml
:
Requirements
- Magento 2.4.5 or higher
- PHP 8.1 or higher
- blackbird/extensions-core >= 100.0.9
Support
- If you have any issue with this code, feel free to open an issue.
- If you want to contribute to this project, feel free to create a pull request.
Contact
For further information, contact us:
- by email: [email protected]
- or by form: https://black.bird.eu/en/contacts/
Authors
- Blackbird Team - Maintainer - They're awesome!
License
This project is licensed under the MIT License - see the LICENSE file for details.
That's all folks!