I have a table of data, I added a delete button in each row. The controller action is well executed and the row is deleted, but I need to manually refresh Magento cache (FullPageCache to be precise) to see the results. How to manage to see instantly the results without having to manually refresh the cache ?

1 Answer 1


You need to setup following step in your controller. 1. Define constructor – pass Magento\Framework\App\Cache\TypeListInterface and Magento\Framework\App\Cache\Frontend\Pool to your file’s constructor as defined below :

public function __construct(
    Context $context,
    \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList,
    \Magento\Framework\App\Cache\Frontend\Pool $cacheFrontendPool
) {
    $this->_cacheTypeList = $cacheTypeList;
    $this->_cacheFrontendPool = $cacheFrontendPool;

2. Now add following code to the method where you want clear/flush cache

    foreach ($types as $type) {
    foreach ($this->_cacheFrontendPool as $cacheFrontend) {

that's it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.