dakzilla/magento2-cachetags-helper dev-master

Type

magento2-module

License

MIT

Requires
Requires (dev)

None

Suggests

None

Provides

None

Conflicts

None

Replaces

None

Magento 2 Cache Tags Helper

Build Status Code Climate Scrutinizer Code Quality

Displays the cache tags from the current page in the console.

Practical use

Knowing which cache tags are used on a page allows you to selectively invalidate full page cache for certain tags only. This tool allows you to know which cache tags are used so that you can develop your own cache invalidation functionality. An example of that would be to create a cron job that invalidates the full page cache for the home page only:

class Cron {
     protected $_cache;

     public function __construct(
            \Magento\Framework\Cache\FrontendInterface $cache
        ) {
            $this->_cache = $cache;
        }

     public function execute() {
        $this->_cache->clean(\Zend_Cache::CLEANING_MODE_MATCHING_TAG, ['cms_page_2']); // default home page tag in 2.1.x
     }
}

Installation

composer require dakzilla/magento2-cachetags-helper

php bin/magento setup:upgrade

Usage

The module only works in developer mode with full page cache disabled. To disable only the full page cache, run this command:

php bin/magento cache:disable full_page

Upon reloading the page, you should see the cache tags appear in your developer console.

Compatibility

This module has been tested with the 2.1 and 2.2 stable branches of Magento 2.

License

This module is licensed under the MIT License

Copyright 2017 Simon Dakin

Made with ♥ in Montreal