Orange Collar Media
Orange Collar Media
DOCS
ORANGECOLLAR/MODULE-WORDPRESS-INTEGRATION · CACHE TAGS

Cache tags used by the WordPress Integration module

  • Magento
  • Adobe Commerce
  • Hyvä

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:

ConstantTag ValueCovers
CacheTag::POSTWORDPRESS_POSTAll post-related cache entries
CacheTag::CATEGORYWORDPRESS_CATEGORYAll category cache entries
CacheTag::TAGWORDPRESS_TAGAll tag cache entries
CacheTag::MENUWORDPRESS_MENUAll menu cache entries
CacheTag::AUTHORWORDPRESS_AUTHORAll author cache entries

Dynamic Tag Methods

MethodReturnsExample
CacheTag::postTag(int $id)WORDPRESS_POST_{id}WORDPRESS_POST_42
CacheTag::authorTag(int $id)WORDPRESS_AUTHOR_{id}WORDPRESS_AUTHOR_5

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_typeTags Invalidated
postWORDPRESS_POST, WORDPRESS_POST_{object_id}
pageWORDPRESS_POST, WORDPRESS_POST_{object_id}
categoryWORDPRESS_CATEGORY
post_tagWORDPRESS_TAG
nav_menuWORDPRESS_MENU

Manual Cache Purge

To manually purge all WordPress cache entries from the command line:

TERMINAL
$ bin/magento cache:clean full_page block_html

To purge only the WordPress integration cache entries programmatically:

PHP
$cacheTypeList->invalidate([
    \Magento\PageCache\Model\Cache\Type::TYPE_IDENTIFIER,
    \Magento\Framework\App\Cache\Type\Block::TYPE_IDENTIFIER,
]);