Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions system/modules/isotope/library/Isotope/Model/ProductCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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']);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this would not clear the reader pages though, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only the product list uses the ProductCache.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but this method is called all over the place where the cache of products should be cleared. E.g. if the store configuration is changed, the reader pages might display a wrong currency. So it would kinda make sense to clear them as well? Although we would be better off actually implementing the correct tags. Which is why this might not make sense as a quick fix in 2.9 🙈

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although we would be better off actually implementing the correct tags.

I can add the additional cache tags in this PR if you want.

Which is why this might not make sense as a quick fix in 2.9

Why? It's a bug in 2.9 and can easily be fixed there.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idk, its also a feature of Contao that is not supported by Isotope 🤷

Copy link
Contributor Author

@fritzmg fritzmg Dec 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HTTP caching you mean?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cache tags

Copy link
Contributor Author

@fritzmg fritzmg Apr 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But again: it's better than to clear the cache not at all, is it not? Having this issue again in a project.

}
}

/**
Expand Down
6 changes: 6 additions & 0 deletions system/modules/isotope/library/Isotope/Module/ProductList.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
}

/**
Expand Down