From a41e17086a120a1b0a2dd7d927b64976af8f853c Mon Sep 17 00:00:00 2001 From: fritzmg Date: Mon, 2 Dec 2024 13:11:19 +0000 Subject: [PATCH 1/2] Add HTTP cache tags --- .../modules/isotope/library/Isotope/Module/ProductList.php | 6 ++++++ .../isotope/library/Isotope/Module/ProductReader.php | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/system/modules/isotope/library/Isotope/Module/ProductList.php b/system/modules/isotope/library/Isotope/Module/ProductList.php index 7e380c44c8..11b9b6a014 100755 --- a/system/modules/isotope/library/Isotope/Module/ProductList.php +++ b/system/modules/isotope/library/Isotope/Module/ProductList.php @@ -303,6 +303,12 @@ protected function compile() ; $this->Template->products = $arrBuffer; + + // Add cache tag + if (System::getContainer()->has('fos_http_cache.http.symfony_response_tagger')) { + $responseTagger = System::getContainer()->get('fos_http_cache.http.symfony_response_tagger'); + $responseTagger->addTags(['contao.db.tl_iso_product']); + } } /** diff --git a/system/modules/isotope/library/Isotope/Module/ProductReader.php b/system/modules/isotope/library/Isotope/Module/ProductReader.php index 61094c1a50..ff9da0eace 100755 --- a/system/modules/isotope/library/Isotope/Module/ProductReader.php +++ b/system/modules/isotope/library/Isotope/Module/ProductReader.php @@ -127,6 +127,12 @@ protected function compile() $this->Template->product_class = $objProduct->getCssClass(); $this->Template->referer = 'javascript:history.go(-1)'; $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack']; + + // Add cache tag + if (System::getContainer()->has('fos_http_cache.http.symfony_response_tagger')) { + $responseTagger = System::getContainer()->get('fos_http_cache.http.symfony_response_tagger'); + $responseTagger->addTags(['contao.db.tl_iso_product.'.$objProduct->id]); + } } /** From f46a07cb49fa89d23dbf03eba124f9e7b1ed2c91 Mon Sep 17 00:00:00 2001 From: fritzmg Date: Tue, 3 Dec 2024 15:14:37 +0000 Subject: [PATCH 2/2] Invalidate tags in ProductCache::purge() as well --- .../modules/isotope/library/Isotope/Model/ProductCache.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/system/modules/isotope/library/Isotope/Model/ProductCache.php b/system/modules/isotope/library/Isotope/Model/ProductCache.php index 43cc63a1eb..9c95a4693b 100644 --- a/system/modules/isotope/library/Isotope/Model/ProductCache.php +++ b/system/modules/isotope/library/Isotope/Model/ProductCache.php @@ -15,6 +15,7 @@ use Contao\FrontendUser; use Contao\Input; use Contao\Model; +use Contao\System; /** * Isotope\Model\ProductCache represents an Isotope product cache model @@ -227,6 +228,10 @@ public static function deleteForPageAndModuleOrExpired($intPage, $intModule) public static function purge() { Database::getInstance()->query("TRUNCATE " . static::$strTable); + + if (System::getContainer()->has('fos_http_cache.cache_manager')) { + System::getContainer()->get('fos_http_cache.cache_manager')->invalidateTags(['contao.db.tl_iso_product']); + } } /**