
Version 1.2.0: filter cache warmup
Major update adding a cache warmup system so catalog pages load instantly on first visit.
Problem
MySQL 8 can be slow on large catalogs. First load of a filtered page took 15–60 seconds for catalogs over 10 000 products. Bottlenecks:
- Loading category product IDs (
ElementRunner::getIds()) - Computing available filter values (
Filter::getFilters()) - Computing facet counters (
Filter::getSuggestionsForIds())
Solution
The warmup system precomputes and stores all three heavy steps in the database. Warmup runs in the background via Scheduler or manually from the manager. After warmup, catalog pages open in fractions of a second.
New features
Warmup subsystem
An administrator creates a warmup configuration in the new manager tab, specifying the snippet and catalog pages. During warmup the system iterates bound pages and caches:
- baseIds — product IDs in the category
- filter values — values for the filter form
- suggestions — product count per filter value
Auto-created configurations
On first visit to any catalog page, a warmup configuration is created automatically. You do not need to configure every page manually — crawl the catalog once or wait for user traffic.
Snippet call parser
The “Snippet call” field in the configuration editor accepts template code and extracts parameters. Three formats are supported:
{'!mFilter'|snippet:['element' => 'msProducts', 'parents' => $_modx->resource.id]}[[!mFilter? &element=`msProducts` &parents=`5`]]{"element": "msProducts", "parents": 5}Scheduler task
New task mfl_warmup runs warmup on cron in the background. By default it is recurring — every 50 minutes, refreshing cache before TTL expires.
The manager includes Via Scheduler to queue warmup in the background.
“Cache warmup” tab
New tab in mFilter:
- Configuration table with last warmup info
- Editor with call parsing, parameter table, and resource tree
- Warm all, Via Scheduler, per-configuration warmup
- + counters checkbox (on by default)
New database models
| Table | Description |
|---|---|
mfl_warmup_configs | Warmup configs (element, params, cache_key_hash, stats) |
mfl_warmup_config_resources | Config to catalog page bindings (many-to-many) |
Tables are created automatically on install or upgrade.
API
10 new endpoints for configuration management:
| Method | Route | Description |
|---|---|---|
| GET | /warmup-configs | List configurations |
| GET | /warmup-configs/{id} | Get configuration |
| POST | /warmup-configs | Create |
| PUT | /warmup-configs/{id} | Update |
| DELETE | /warmup-configs/{id} | Delete |
| POST | /warmup-configs/{id}/warmup | Warm one configuration |
| POST | /warmup-configs/warmup-all | Warm all |
| POST | /warmup-configs/schedule | Schedule via Scheduler |
| POST | /warmup-configs/parse-snippet | Parse snippet call |
| GET | /warmup-configs/resource-tree | Resource tree |
Improvements
Caching getSuggestionsForIds
Filter::getSuggestionsForIds() now stores results in mfl_cache. Repeated calls with the same parameters read from cache.
UTC cache timestamps
All cache timestamps (expires_at, created_at, updated_at) are stored in UTC via gmdate(). Fixes premature cache expiry when cron runs in UTC and web processes use a local timezone.
TvIndexer
TvIndexer::indexResource() now indexes only TVs used in filter configuration instead of all resource TVs. Reduces indexing load.
Legacy warm_suggestions removed
Removed legacy HTTP-based suggestion warmup (file_get_contents with SSL verification disabled). Replaced with direct execution via mfl_warmup.
Project tuning
Warmup interval and TTL
| Catalog size | TTL | Warmup interval | Description |
|---|---|---|---|
| Up to 1 000 products | 3600 | 3000 | Default |
| 1 000 — 10 000 | 7200 | 6000 | Every 100 min |
| 10 000 — 100 000 | 14400 | 10800 | Every 3 hours |
| 100 000+ | 86400 | 43200 | Twice per day |
- TTL — system setting
mfilter.cache_lifetime - Interval —
intervalfield on Scheduler taskmfl_warmup
Внимание
Interval must be less than TTL. Account for warmup duration — for ~200 000 products warmup can take ~30 minutes.
When the product catalog changes
| Scenario | Action |
|---|---|
| Regular price/stock import | Automatic — recurring task refreshes cache |
| Bulk new product import | Run warmup manually from the manager |
| Filter structure changed | Clear cache + run warmup |
Upgrade
Before upgrading
- Back up the database
After upgrading
- Clear MODX cache
- Open the Cache warmup tab
- Create a configuration or wait for auto-creation when the catalog is visited
- Run warmup Via Scheduler
- Ensure cron is configured for Scheduler
New tables
mfl_warmup_configs and mfl_warmup_config_resources are created automatically when the package is installed.
New Scheduler task
Task mfl_warmup is registered automatically. Without Scheduler, warmup is only available from the manager (Warm all).
Results
After warmup on a catalog of 200 000 products and 100 categories:
| Metric | Without warmup | With warmup |
|---|---|---|
| First page load | 15–60 sec | < 1 sec |
| Full catalog warmup | — | ~8–30 min (background) |
