Last Updated: February 25, 2016
·
2.153K
· mogensen

Fixing Cache for extensions in TYPO3

"Caching in tt_news, cal_base and X sucks!"

Well, these extensions definitely have a less than optimal caching.

tl;dr

Use Cachecontrol to automatically configure extensions such as tt_news and cal to use TYPO3s Caching Framework.

Scenario 1:

The backend user creates a new news in tt_news about the fantastic event they had at the office this weekend.
He looks at the frontend and notices that the news isn't there!!
This happens because:

  • TYPO3 has a powerful caching that caches all the news pages so it does not need to render all extensions every time a user visits the page

Scenario 2:

We have a list of future events on our frontpage. We would like to remove previous events when we pass midnight.

If we don't then our future events will contain events from yesterday.

How can we make the news appear on the page?

We have a couple of different options:

  1. The backend user is granted access to clear page cache
  2. Rewrite the extension to use the fantastic caching framework
  3. Fix the caching problem by using an other extension

Lets look at the different solutions:

1. BE user with clear cache permissions

Pros:
Fast and easy!

Cons:
This solution demands that the user remembers to clear the cache on all pages that contains the extension. If the user forgets to clear the cache on the frontpage that always shows the latest news, visiting users will see other news in the news archive than on the frontpage.

This does not fix the calender extensions problems, we can't expect the be user to login at midnight and clear cache for us at the right pages? Can we?

2. Rewriting extensions / choosing new extensions

Pros:
Fixes both scenarios if we chose the right extensions.

Cons:
We need to change the workflow for all the be users, depending on which extensions we chose. We may also need to find a way to port our production data from one extension to another, or accenpt to lose it!

3. Fixing the problems with Cache Control

Use Cachecontrol from TER to fix all the problems without giving users more permissions, without hacking existing extensions, and without migrating all data to other extensions.

Cache Control

A genius new extension from Karsten Madsen.

What does it do?

  • It registers pages contain the extensions you configure it to monitor
  • When a be user edits a news record or a calender event it clears the cache for only the pages where these extensions are active
  • If configured with the clearAtMidnight flag it clears the pages containing the monitored extensions at midnight
  • Only clear cache for the subtree contained in the specific rootpage (if your installation have more sites "rootpages")
  • Allows the user to configure the cache control extension to manage cache for all other extensions