b13 / menus

TYPO3 Extension for creating fast menus in a fast fashion
GNU General Public License v2.0
54 stars 21 forks source link

Optimize clear frontend/page cache behaviour #51

Closed tobiwollender closed 2 months ago

tobiwollender commented 3 years ago

After editing a page, the complete frontend (page?) cache is deleted, so navigation changes will be directly visible to the visitors. That's very good, that editors don't have to press "clear frontend cache" after every change manually.

Problem on large sites is, that the whole page cache is deleted. Even if you have more site configurations and the change only affects one site. Would it be possible, to restrict the cache clearing to the current site configuration?

And not all changes of the page properties are directly relevant to clear the whole page cache. Mostly (in my known projects) it's the title and slug - changes on these fields should clear the cache for a correct navigation. But many other fields are only relevant for the current page, and so it's enough, to only clear the cache of that specific site. Maybe it's possible, to configure the fields in the future, which trigger a cache-clearing for the whole site.

I think with optimizations in that area, the "clear cache"-button could be deactivated most of the time.

toccamonium-fe commented 3 years ago

Was just preparing a mail for this issue, as it is a performance problem with large websites. Would be super cool, if there would be found a solution for this.

bmack commented 3 years ago

Sure, but IMHO the only solution I see would be to build a frontend page out of separate cached entries, and then flush and replace these parts that are related to a tag, and rebuild this. I see your point, but I think this means more work within TYPO3 Core, not in EXT:menus? Otherwise you'd get outdated menus on other pages (which is exactly what happens with HMENU).

seirerman commented 2 years ago

Had the same issue on a big site, caches were often empty during the day, You don't even need to change a value, simply clicking "Save" clears the cache for every page. So EXT:menus actually cost us performance instead of improving it. :-)

My dirty "solution" was to simply disable these two lines in /Classes/Hooks/DataHandlerHook.php:

$cacheManager = GeneralUtility::makeInstance(CacheManager::class);
$cacheManager->flushCachesByTags($menuTags);

Now the pages stay in the cache until midnight (config.cache_clearAtMidnight=1) and the caches are refilled again shortly after with lochmueller/seocli. It can take up to a day until the menus are up to date again, but that's fine for us. So far, no customers have complained. And EXT:menus still helps a lot with page generation times.

But I'm sure there's a better fix for this problem. Maybe a simple TypoScript setting to switch it on or off?

achimfritz commented 2 months ago

Hi guys, just unset the DataHandlerHook, if you do not want Cache Flushing unset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['clearCachePostProc']['tx-menus']);