Skip to Main Content
[Translate to English:]

Let the cache flow

F7 publishes new Extension in the TYPO3 Extension Repository

TYPO3 is known for its powerful and flexible caching mechanism, which can also handle complex relationships. This is well documented in the official documentation or in the series of articles by b13. However, there are scenarios in which the existing mechanisms (such as tags) reach their limits. This is where the "CacheFlow" extension comes in, which enables continuous and automatic refreshing of the cached pages.

Basic Idea and Mechanic

"CacheFlow" ensures that the oldest cached pages are regularly retrieved, their cache invalidated and then freshly cached. Prioritised pages, such as those with changed visibility, are automatically recognised and processed first.

This guarantees that visitors to the TYPO3 website are always presented with up-to-date content. A typical example is the use of content from one page - such as an image from the page properties as a teaser - on other pages. If an editor changes this image, only the cache of the actual page is invalidated - but not that of all pages on which the teaser appears. In the case of unclear referencing, the entire cache would have to be emptied every time a change is made, which is inefficient.

This is where "CacheFlow" comes in: The normal TYPO3 cache lifecycle remains unchanged, but in the background all pages of the website are cyclically invalidated one after the other and the cache is refreshed. This means that changes such as teaser images are processed promptly without affecting the performance of the website. To make this possible, a new field called 'last_flowed' is added to the 'pages' table. The current timestamp is saved in this field for each run on which a page is recorded. During the initial run, all pages are captured; the batch size can then be configured. In each subsequent run, the prioritised pages are processed first, while the rest are supplemented by the pages with the oldest 'last_flowed' entries. The whole process is executed via a CLI command, which is called regularly via a scheduler task.

Dashboard Widget and Performance

There is a widget in the backend dashboard that displays relevant statistics (duration of the current run, average time of all runs, estimated time for the total run, date of the oldest run). This should help to get a better overview of status and performance. Our tests with several larger projects (5,000 to 10,000 pages) have shown that a total run took an average of 1 to 2 hours. This means that CacheFlow guarantees that even changes to complex contexts can be played out promptly. There is no impairment of server performance in productive operation due to the processes in the background.

Critical Con­sid­ar­a­tion

In order to keep the extension as minimalistic as possible, minor weaknesses were deliberately accepted. For example, if a page or content element is changed and the "normal" TYPO3 core cache invalidation is triggered (or the cache is cleared by command), the value of "last_flowed" does not change. This could lead to these pages being cached again earlier than other (possibly relevant pages). To improve this, you could consider monitoring the CacheFlushEvent or using a DataHandler hook.

Conclusion

The "CacheFlow" extension is particularly useful if the website has complex content elements and data structures that are no longer covered by the TYPO3 caching configuration. In this case, the extension offers a simple and low-maintenance addition to ensure that content changes arrive in the frontend promptly, correctly and with high performance.

Extension: extensions.typo3.org/extension/cacheflow
Documentation: docs.typo3.org/p/f7media/cacheflow/1.0/en-us
Repository: github.com/f7media/cacheflow