When investigating Magento caching in more detail, you may encounter X-Magento-Tags. Magento uses these tags to describe which entities contribute to a cached response, such as products, categories or CMS pages.

Typical cache tags look like this:

The structure is simple: the first part identifies the entity type, while the following number is usually the entity’s Entity ID. cat_p_123 stands for product ID 123, cat_c_42 for category ID 42 and cms_p_5 for CMS page ID 5.

Magento defines these prefixes on the relevant entities, for example in product code using cat_p. The entity ID is appended to produce a unique cache tag.

If product 123 changes, Magento can invalidate cache entries carrying the tag cat_p_123 instead of clearing the entire full page cache. Varnish uses this information with the cached objects to invalidate specific content.

The tags are generated in part by Magento’s IdentityInterface and its method getIdentities(). Custom blocks and modules can also declare which data their cached output depends on.

Cacheable GraphQL requests use these tags too, allowing product, category and CMS data to be invalidated selectively.

Missing or incorrect dependencies in custom code can lead to a particularly awkward problem: The cache works, but continues to serve stale content after the underlying data changes.

What Are X-Magento-Tags?
Need help implementing this solution, or still looking for a fix to your Magento problem? Get in touch and I will be happy to help with your project.
Tags: