Review main Merged

81930[BUGFIX] Respect endtime of page when calculating the lifetime

Sascha Nowak CR +2 V +2 Easy +5 −0 updated 11/30/23, 17:05

Commit message

When the endtime of a page is lower than the default lifetime (24h),
the calculation did not respect the endtime and set the lifetime to
default lifetime. This lead to cache entries with incorrect lifetimes.

The upper bound of the cache lifetime is now additionally clamped to
the endtime of the current page.

Review

  • Code review CR +2 Done
    • Benni Mack +2
    • Benjamin Franzke +1
  • Verified V +2 Done
    • Benni Mack +2
    • Benjamin Franzke +1
    • core-ci +1 CI

Issues 2

Files 1

Review log 1724

  1. Sascha Nowak uploaded patch set 1 11/23/23, 16:12

  2. core-ci voted on patch set 1 V +1 11/23/23, 16:22 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/49756

  3. core-ci commented on patch set 1 11/23/23, 17:08 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/49794

  4. Andreas Wolf commented on patch set 1 11/23/23, 18:55

    Restrict => respect?
    … sets the lifetime …

    CacheLifetimeCalculator.php:54

    calculateLifetimeForRow_%s_%d

    ModifyCacheLifetimeForRowEvent.php:29

    These could be public and we could drop the getters then, right?
  5. Benni Mack commented on patch set 1 11/24/23, 08:04

    ModifyCacheLifetimeForRowEvent.php:24

    can't we re-use the already existing ModifyCacheLifetimeForPageEvent?
  6. Sascha Nowak commented on patch set 1 11/24/23, 08:31

    ModifyCacheLifetimeForRowEvent.php:24 Reply

    The ModifyCacheLifetimeForPageEvent does not have a tablename. Identifying the object you can manipulate is not possible. What do you think about deprecating the ModifyCacheLifetimeForPageEvent and use only the new ModifyCacheLifetimeForRowEvent?
  7. Sascha Nowak uploaded patch set 2 V +1 11/24/23, 08:33

  8. Benni Mack commented on patch set 2 11/24/23, 08:34

    ModifyCacheLifetimeForRowEvent.php:24 Reply

    If your plan is to add this change to v12, then adding a new Event (= a new feature) is usually not an option. If we're going v13 only, I could imagine keeping both events (I use the existing Event actually and its position and place is quite useful as it is at the very end).
  9. Sascha Nowak commented on patch set 2 11/24/23, 08:57

    ModifyCacheLifetimeForRowEvent.php:24 Reply

    Thanks for your input. I will rework this change and only fix the bug in this change and add the event as feature in a separate change for v13.
  10. Sascha Nowak uploaded patch set 3 11/24/23, 09:09

  11. core-ci voted on patch set 3 V +1 11/24/23, 09:18 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/49848

  12. core-ci voted on patch set 2 V -1 11/24/23, 09:36 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/49839

  13. Benni Mack commented on patch set 3 CR +1 11/27/23, 08:15

    Reply

    Done

    Reply

    Done

    CacheLifetimeCalculator.php:54 Reply

    Done

    ModifyCacheLifetimeForRowEvent.php:24 Reply

    Done

    ModifyCacheLifetimeForRowEvent.php:29 Reply

    Done
  14. Christian Kuhn updated the commit message in patch set 4 CR +1 V +1 11/27/23, 11:32

  15. Christian Kuhn voted on patch set 4 CR +1 V +1 11/27/23, 11:32

  16. core-ci voted on patch set 4 V +1 11/27/23, 11:38 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/49980

  17. Benjamin Franzke commented on patch set 4 CR -1 11/30/23, 14:19

    on it. Two things im unsure about: 1) I see some seconds offsets in expires and max-age header, e.g.: expires: Thu, 30 Nov 2023 14:10:43 GMT While I'd expect this to always be normalized to the start of the minute (as configured in backend and even stored in the database): expires: Thu, 30 Nov 2023 14:10:00 GMT Looks like we fail to normalize (later) – so basically ACCESS_TIME doesn't work here. I guess you picked ACCESS_TIME from the code below. But the comment of that code "It is ok that we do not take seconds into account here because" simply seems to be a wrong promise. (Did I mention I hate (such) comments for exactly those reasons? :) They can never be trusted.) It would work if we'd use EXEC_TIME. Sorry, I need to "understand" this is order to fix this "properly" in order to avoid caching too long (up to 60 seconds) 2) The record-entime checker adds +1 to the timedifference, with a strange justification that "fears" basically not to regenerate content when the page is requested on the last cache-second: https://review.typo3.org/c/Packages/TYPO3.CMS/+/81930/4/typo3/sysext/frontend/Classes/Cache/CacheLifetimeCalculator.php#117 Well, IMO that'd actually be the correct behaviour (last second should still be cached), so I'd like to check that, in order to implement "endtime" algorithms that are aligned between pages and content records.
    than
  18. Benjamin Franzke uploaded patch set 5 CR +1 V +1 11/30/23, 14:44

  19. Benjamin Franzke commented on patch set 5 11/30/23, 14:45

    Reply

    Ok, So ACCESS_TIME is used by the record-endtime-checker in order to "normalize" the queries for the database (in order for the mysql query cache to work in case multiple requests are processed in one second). so ACCESS_TIME really isn't the right tool for our case, becasue the resulting cache-timeout will be calculated based on EXEC_TIME: https://github.com/TYPO3/typo3/blob/594c1cd43afe2f052faa4ec092e04b94658ee889/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php#L2211 So I switched to patch to use EXEC_TIME. The record-endtime-cachetimeout calculation still looks fishy to me, but that's something for a separate change, so I'd say: let's merge.

    Reply

    Done
  20. core-ci voted on patch set 5 V +1 11/30/23, 14:50 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/50170

  21. Benjamin Franzke uploaded patch set 6 CR +1 V +1 11/30/23, 15:52

  22. core-ci voted on patch set 6 V +1 11/30/23, 15:58 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/50174

  23. Benni Mack voted on patch set 6 CR +2 V +2 11/30/23, 17:05

  24. Benni Mack merged patch set 7 11/30/23, 17:05