Contao: Cache tag invalidation

Created on 10 Aug 2020  路  3Comments  路  Source: contao/contao

As discussed in https://github.com/contao/contao/pull/2103#issuecomment-671283944, we are currently always invalidating both the specific tag and the general "category" tag (e.g. contao.db.tl_news.61 and contao.db.tl_news), which kind of renders the specific tag useless. Maybe we can improve this?

bug

Most helpful comment

As discussed in Mumble on August 27th, these tags should be set for e.g. a news item:

  • news reader: tl_news.61, tl_content.11
  • news list: tl_news_archive.1, tl_news.61, tl_news.62, tl_content.11, tl_content.12

Then:

  • Case 1: A news archive is created /edited/unpublished/resorted/removed -> invalidate tl_news_archive, tl_news_archive.1, tl_news.61, tl_news.62, tl_content.11, tl_content.12
  • Case 2: A news item is created/edited/unpublished/resorted/removed -> invalidate tl_news_archive, tl_news_archive.1, tl_news.61, tl_content.11

So all parent and child IDs need to be invalidated. Only the top parent record gets a general tag without ID.

All 3 comments

We also need to discuss and fix this:

@ausi wrote: If you add a new news article the list module on the website will not be tagged with this new contao.db.tl_news.ID and therefore the new article would not show up. If we invalidate the parent contao.db.tl_news_archive.ID (as we did before this PR) the news list module would show the new article as soon as it was published.

@Toflar wrote: But that's only "by chance". It only works if there is a parent table. If there's not, it wouldn't work. We need special handling for "create".

As discussed in Mumble on August 27th, these tags should be set for e.g. a news item:

  • news reader: tl_news.61, tl_content.11
  • news list: tl_news_archive.1, tl_news.61, tl_news.62, tl_content.11, tl_content.12

Then:

  • Case 1: A news archive is created /edited/unpublished/resorted/removed -> invalidate tl_news_archive, tl_news_archive.1, tl_news.61, tl_news.62, tl_content.11, tl_content.12
  • Case 2: A news item is created/edited/unpublished/resorted/removed -> invalidate tl_news_archive, tl_news_archive.1, tl_news.61, tl_content.11

So all parent and child IDs need to be invalidated. Only the top parent record gets a general tag without ID.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

leofeyer picture leofeyer  路  3Comments

fritzmg picture fritzmg  路  3Comments

Alibi-Contao picture Alibi-Contao  路  3Comments

mathContao picture mathContao  路  3Comments

issue-bot picture issue-bot  路  4Comments