Idea behind
On bigger pages you have quite often big menus with lots of pages and levels (like responsive menus or flyout menus)
The rendering of these menus is quite heavy and is normally done on every rendered page.
If you do not need to mark active or current pages or do this on browser side via Javascript, then the menu might be idential on all / several pages.
Perfect to be cached!, (*1)
Currently we use it only for menus, other TypoScript objects should work, but probably the cache invalidation needs refinement then., (*2)
HINT FOR DEBUGGING: we activate caching only if no FE user is logged in. Every BE user gets her own individual cache., (*3)
lib.menu.sector = HMENU
lib.menu.sector {
[...]
}
// only use caching if no fe_user is logged in, else just stay with original TS
lib.menu.sector_cached < lib.menu.sector
[loginUser('*') == false]
lib.menu.sector_cached >
lib.menu.sector_cached = USER
lib.menu.sector_cached {
userFunc = ElementareTeilchen\Etcachetsobjects\TypoScriptCache->databaseBackend
conf < lib.menu.sector
cacheTime = 0 // "0" means unlimited liftime, cleared via backend saving hook on page changes
//here we can set parameter needed for creating different cache entries
additionalUniqueCacheParameters = COA
additionalUniqueCacheParameters {
10 = TEXT
10.value = 0
10.override.data = siteLanguage:languageId
20 = TEXT
20.value = {$theme.pages.sectorstart_id}
}
}
[global]
That one is used when you have a very big and deep page tree. On a certain level you don't want to flyout anymore, but show subpages only for the current page, (*4)
lib.menu.sector = HMENU
lib.menu.sector {
[...]
}
[loginUser('*') == false]
lib.menu.sector_cached >
lib.menu.sector_cached = USER
lib.menu.sector_cached {
userFunc = ElementareTeilchen\Etcachetsobjects\TypoScriptCache->databaseBackend
conf < lib.menu.sector
cacheTime = 0 // "0" means unlimited liftime, cleared via backend saving hook on page changes
//here we can set parameter needed for creating different cache entries
additionalUniqueCacheParameters = COA
additionalUniqueCacheParameters {
10 = TEXT
10.value = 0
10.override.data = GP:L
20 = TEXT
20.value = {$theme.pages.sectorstart_id}
// special handling because of level 5/6
// if on level 4 and page has subpages or if on level 5 and deeper we have individual menus
30 = USER
30.userFunc = ElementareTeilchen\Etcachetsobjects\MenuVariantCheck->levelGroupIdentifier
30.sectorstartId = {$theme.pages.sectorstart_id}
30.individualMenusComingAtLevel = 4
}
// no ContentObject like COA, TEXT needed, we just want the configuration value
additionalTags {
10 = sector_{$theme.pages.sectorstart_id}
#20 =
}
}
[global]
Usage example 3: cache expensive lib. object which is used several times on same page
lib.pageRootlineCategoryId = CONTENT
lib.pageRootlineCategoryId {
[...]
}
lib.pageRootlineCategoryId_cached = USER
lib.pageRootlineCategoryId_cached {
userFunc = ElementareTeilchen\Etcachetsobjects\TypoScriptCache->transientBackend
conf < lib.pageRootlineCategoryId
}
// then just replace _lib.pageRootlineCategoryId_ with _lib.pageRootlineCategoryId_cached_ whereever you use it.
Cache Invalidation
In the Extension Manager you can define which variant of invalidation you need., (*5)
PageTS Setting
Only clear cache of configured cache tags., (*6)
Specify which cache tags should be flushed when editing pages.
Configure using Page TSconfig.
Use cache tags you set in your TypoScript when caching menus / libs., (*7)
When configuring your cached menus / libs, you can add additional cache tags.
Example:, (*8)
lib.menu.sector_cached {
userFunc = ElementareTeilchen\Etcachetsobjects\TypoScriptCache->databaseBackend
conf < lib.menu.sector
...
// no ContentObject like COA, TEXT needed, we just want the configuration value
additionalTags {
10 = sector_{$theme.pages.sectorstart_id}
20 = cacheTag1
30 = cacheTag2
}
}
Example TSconfig setting:, (*9)
tx_etcachetsobjects.clearByTags = cacheTag1, cacheTag2
Site based
Clear cache of whole site in which the edited page record resides in., (*10)
From all pages
Clear all cache when a page record is edited., (*11)