akeneo / magento2-connector-community

Akeneo Connector for Magento 2
Open Software License 3.0
88 stars 89 forks source link

Improve full page cache cleaning #150

Open Tjitse-E opened 4 years ago

Tjitse-E commented 4 years ago

Hi,

Thanks for writing this module, it's a real improvement over the old Pimgento module!

I have one suggestion, I see that the Magento FPC and block_html caches are cleared after processing the new entities from Akeneo. Here for example: \Akeneo\Connector\Job\Product::cleanCache. In the product example, this means that all of the pages are purged from the FPC after a Akeneo import. It would be more elegant I think to use the build in clean_cache_by_tags event, so we will partically clean the FPC and only the updated records will be purged.

Magento also does this a lot in the core modules, for example in the module-catalog-inventory. Check \Magento\CatalogInventory\Model\Indexer\Stock\CacheCleaner::clean

$productIds = $this->getProductIdsForCacheClean($productStatusesBefore, $productStatusesAfter);
if ($productIds) {
  $this->cacheContext->registerEntities(Product::CACHE_TAG, array_unique($productIds));
  $this->eventManager->dispatch('clean_cache_by_tags', ['object' => $this->cacheContext]);
}

Would this be something you'd consider for this module?

badger-adam commented 2 months ago

This should be a high priority issue. Flushing the entire website's cache every time even a single product is updated has massive implications on high volume websites. It's worse than that too because it does it at the end of every import job.