90125[BUGFIX] Consider content object cache lifetimes in HTTP cache headers
Commit message
Review
-
Code review CR +2 Done
- Christian Kuhn +2
- Stefan Bürk +1
- Jörg Bösche +1
- Sascha Nowak +1
-
Verified V +2 Done
- Christian Kuhn +2
- Stefan Bürk +1
- Sascha Nowak +1
- core-ci +1 CI
Issues 1
Files 3
Review log 3341
Show 1416 earlier messages
-
Benni Mack uploaded patch set 1 07/22/25, 21:26
-
core-ci voted on patch set 1 V +1 07/22/25, 21:33 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/82144
-
Markus Klein voted on patch set 1 CR +1 07/23/25, 09:14
-
Simon Schaufelberger voted on patch set 1 CR +1 V +1 07/23/25, 14:19
-
Markus Klein voted on patch set 1 V +1 07/23/25, 14:23
-
Oli Bartsch voted on patch set 1 CR +1 V +1 07/24/25, 09:03
-
Benjamin Franzke commented on patch set 1 CR -1 07/25/25, 11:09
I would like to check this, the idea of Sascha cache collector was that all cache-influencing components are taken into account in `resolveLifetime()` by taking the minium cache lifetime of all cache tags from pages and content elments. With this change the minimium is effectively taken twice: ``` min(min(ContentLifeTime, PageLifeTime), ContentLifeTime) # instead of min(PageLifeTime, ContentLifeTime) ``` I'll check this, also cc @typo3@saschanowak.me as the author of the cache data collector. -
Sascha Nowak commented on patch set 1 07/25/25, 11:52
Reply
Thanks for tagging me. The idea was, when you add a CacheTag with a lifetime, which is done in the ContentObjectRenderer, then the shortest lifetime of all CacheTags should be used for the page cache entry and the cache control header. The function restrictMaximumLifetime is only there that we can implement features like "clearCacheOnMidnight". @benni@typo3.org when I understand the szenario correctly then you have a page with a long lifetime (24h) and a content element with a short lifetime (1h) and the content element has no access restrictions like start- and enddate. The bug is that the cache control max-age header is 24h and not 1h? I we have one or two more days for review I will try to reproduce the bug and test your change? -
Benjamin Franzke commented on patch set 1 07/25/25, 12:18
Reply
FYI: Benni provided me with the following reproduction example (didn't verify myself yet): https://forge.typo3.org/issues/83045#note-3 I'd appreciate if you could verifiy this and we definitely have the time to wait 😊 Thanks in advance! -
Sascha Nowak commented on patch set 1 07/25/25, 16:52
ContentObjectRenderer.php:696I've identified the root cause of the issue. The current implementation doesn't associate a cache tag or a corresponding lifetime with the generated data. In the specific case referenced in the ticket, no cache tag is assigned at all—meaning the calculated lifetime isn't persisted or reused. A robust solution would be to always attach the cache key as a tag (hashed to a short MD5) and associate the intended lifetime directly with that tag. Once that's in place, the CacheDataCollector handles the rest correctly and consistently. Below is the code that resolves the issue based on the scenario described in the ticket: ``` $tags = [ substr(md5($key), 0, 10), ...$this->calculateCacheTags($cacheConfiguration) ]; $lifetime = $this->calculateCacheLifetime($cacheConfiguration); $cachedData = [ 'content' => $content, 'cacheTags' => $tags, ]; $cacheFrontend->set($key, $cachedData, $tags, $lifetime); $this->getRequest()->getAttribute('frontend.cache.collector')->addCacheTags( ...array_map(fn(string $tag) => new CacheTag($tag, $lifetime ?? PHP_INT_MAX), $tags) ); ``` we can do the same on the other part below. what do you think about the solution @benni@typo3.org? -
Benni Mack commented on patch set 1 07/31/25, 16:42
ContentObjectRenderer.php:696Replysounds like good to me -
Sascha Nowak uploaded patch set 2
CR +1V +108/15/25, 05:19 -
Sascha Nowak uploaded patch set 3 08/15/25, 05:24
-
Sascha Nowak uploaded patch set 4 08/15/25, 05:24
-
Sascha Nowak voted on patch set 4 CR +1 V +1 08/15/25, 05:27
-
core-ci voted on patch set 2 V -1 08/15/25, 05:27 Copied votes on follow-up patch sets have been updated: * Verified-1 has been copied to patch set 3 (copy condition: "changekind:NO_CHANGE"). Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/83433
-
Sascha Nowak commented on patch set 4 08/15/25, 05:27
Reply
DoneContentObjectRenderer.php:696ReplyDone -
Sascha Nowak uploaded patch set 5
CR +1V +108/15/25, 05:29 -
Sascha Nowak voted on patch set 5 CR +1 V +1 08/15/25, 05:30
-
core-ci voted on patch set 3 V -1 08/15/25, 05:34 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/83434
-
core-ci voted on patch set 4 V -1 08/15/25, 05:35 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/83435
-
core-ci voted on patch set 5 V -1 08/15/25, 05:37 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/83436
-
Sascha Nowak uploaded patch set 6
CR +1V +108/15/25, 05:50 -
core-ci voted on patch set 6 V +1 08/15/25, 05:58 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/83438
-
Andreas Kienast voted on patch set 6 CR +1 08/15/25, 06:36
-
Christian Kuhn commented on patch set 6 08/15/25, 09:23
this solution works. the drawback: we now "invent" cache tags (which are added to hash & page cache) only to transport the lifetime information, due to our current api that combines both. these tags have no other job than that and also can't be used for eviction, which is their real use case. -
Christian Kuhn commented on patch set 6 08/15/25, 09:44
Reply
looking at this a bit closer, i wonder if we can't simply call 'frontend.cache.collector'->restrictMaximumLifetime() if there are no tags in TS but only key and lifetime, which should reduce lifetime of the page cache - similar to what benni proposed in set 1 already? -
Sascha Nowak uploaded patch set 7
CR +1V +108/15/25, 14:41 -
Sascha Nowak commented on patch set 7 08/15/25, 14:43
Reply
Done -
core-ci voted on patch set 7 V -1 08/15/25, 14:50 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/83463
-
Sascha Nowak uploaded patch set 8
V -108/18/25, 05:27 -
core-ci voted on patch set 8 V +1 08/18/25, 05:34 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/83554
-
Jörg Bösche voted on patch set 8 CR +1 08/18/25, 10:14
-
Christian Kuhn commented on patch set 8 08/18/25, 10:42
test main: page = PAGE page.10 = TEXT page.10.value = <h3>Benni in default</h3><br> page.20 = TEXT page.20.date = Y-m-d H:i:s page.20.cache.key = mykey page.20.cache.lifetime = 30 -> page cache with 'casual' tags is generated, lifetime 30 seconds, hash cache row is generated, no tags, lifetime 30 seconds. -> quick reload: content delivered from cache -> reload after 30 seconds: contend recreated, new cache rows. --> all good. test main: page = PAGE page.10 = TEXT page.10.value = <h3>Benni in default</h3><br> page.20 = TEXT page.20.date = Y-m-d H:i:s page.20.cache.key = mykey page.20.cache.tags = foo_1, foo_2 page.20.cache.lifetime = 30 -> page cache with the two additional tags is created, lifetime 30 seconds, hash cache row i generated, the two tags, lifetime 30 seconds -> quick reload: content delivered from cache -> reload after 30 seconds: content recreated, new cache rows. --> all good. -
Christian Kuhn commented on patch set 8 CR +1 V +1 08/18/25, 10:48
Reply
same result in v13 -
Sascha Nowak voted on patch set 8 CR +1 V +1 08/18/25, 11:16
-
Stefan Bürk commented on patch set 8 CR -1 08/18/25, 11:42
Reviewing ... -
Stefan Bürk voted on patch set 8 CR +1 V +1 08/18/25, 12:33
-
Christian Kuhn voted on patch set 8 CR +2 V +2 08/18/25, 12:33
-
Christian Kuhn commented on patch set 8 08/18/25, 12:34
Reply
Done -
Christian Kuhn merged patch set 9 08/18/25, 12:55