ORANGECOLLAR/MODULE-WORDPRESS-INTEGRATION · CACHE TAGS
Cache tags used by the WordPress Integration module
The module uses Magento’s tagged cache system. Cache entries are tagged when saved, allowing targeted invalidation without flushing the entire cache.
Cache Tag Constants
Defined in Model/Cache/CacheTag.php:
| Constant | Tag Value | Covers |
|---|---|---|
CacheTag::POST | WORDPRESS_ | All post-related cache entries |
CacheTag::CATEGORY | WORDPRESS_ | All category cache entries |
CacheTag::TAG | WORDPRESS_ | All tag cache entries |
CacheTag::MENU | WORDPRESS_ | All menu cache entries |
CacheTag::AUTHOR | WORDPRESS_ | All author cache entries |
Dynamic Tag Methods
| Method | Returns | Example |
|---|---|---|
CacheTag::postTag(int $id) | WORDPRESS_ | WORDPRESS_ |
CacheTag::authorTag(int $id) | WORDPRESS_ | WORDPRESS_ |
Tag Usage in Repositories
When the PostRepository caches a single post, it saves it with both the general WORDPRESS_POST tag and the specific WORDPRESS_POST_{id} tag. This allows:
- Purging all posts at once (e.g., on a bulk publish) using
WORDPRESS_POST - Purging a single post (e.g., on a single post update) using
WORDPRESS_POST_{id}
Webhook to Cache Tag Mapping
When a webhook arrives from WordPress, the object_type field determines which tags to purge:
object_type | Tags Invalidated |
|---|---|
post | WORDPRESS_, WORDPRESS_ |
page | WORDPRESS_, WORDPRESS_ |
category | WORDPRESS_ |
post_ | WORDPRESS_ |
nav_ | WORDPRESS_ |
Manual Cache Purge
To manually purge all WordPress cache entries from the command line:
$ bin/magento cache:clean full_page block_html To purge only the WordPress integration cache entries programmatically:
$cacheTypeList->invalidate([
\Magento\PageCache\Model\Cache\Type::TYPE_IDENTIFIER,
\Magento\Framework\App\Cache\Type\Block::TYPE_IDENTIFIER,
]);