Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HTTP cache tags #2553

Open
wants to merge 2 commits into
base: 2.9
Choose a base branch
from
Open

Add HTTP cache tags #2553

wants to merge 2 commits into from

Conversation

fritzmg
Copy link
Contributor

@fritzmg fritzmg commented Dec 2, 2024

Currently, if a page with a product list is in the shared HTTP cache and a new product is added, deleted or a product is changed, the cache will not be invalidated. Likewise if a product detail is in the shared HTTP cache and that product is changed, the shared cache is also not invalidated.

This PR fixes that by adding at least the general contao.db.tl_iso_product cache tag for any product list and the contao.db.tl_iso_product.* cache tag for any product detail. Both will get automatically invalidated by the DataContainer in the back end when editing products.

@aschempp
Copy link
Member

aschempp commented Dec 3, 2024

This might partially work, but I would suggest to at least also also add cache clearing to Backend::truncateProductCache

@fritzmg
Copy link
Contributor Author

fritzmg commented Dec 3, 2024

This might partially work

Partially is still better than never 😁.

but I would suggest to at least also also add cache clearing to Backend::truncateProductCache

Makes sense 👍. I will add it to the PR.

@fritzmg
Copy link
Contributor Author

fritzmg commented Dec 3, 2024

I have added it to ProductCache::purge() instead, wdyt?

@@ -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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants