Task #89280

Epic #83968: PSR-11 Initiative

TypoScript Template Constant Editor flushes to many caches, results in slow frontend responses due to DI rebuild

Added by Benjamin Franzke about 2 months ago. Updated 22 days ago.

Status:
Resolved
Priority:
Should have
Category:
TypoScript
Start date:
2019-09-25
Due date:
% Done:

100%

TYPO3 Version:
10
PHP Version:
Tags:
Complexity:
Sprint Focus:

Description

Reported by Simon Schaufelberger via Slack channel #psr11-initiative:

Sunday, August 4th 3:21 pm

The problem also is that the DI cache gets flushed way too often.
I just saved a typoscript constant in the template module and the whole cache was empty again afterwards.
Wondering why the DI cache needs to get flushed in such a case

The reason is the usage of clear_cacheCmd('all') which flushes all core caches like ext_localconf and DI cache.
Also opcache is flushed. These caches are unaffected by TypoScript Template change.s

Associated revisions

Revision 25a8b704 (diff)
Added by Benjamin Franzke 22 days ago

[TASK] Consolidate cache clearing in TypoScript edit backend controllers

The TypoScript editing module "Template" currently has different
cache flush behaviours, depending on how the data is being modified:

a) The DataHandler cache command 'all' is triggered when a TypoScript
constant is changed via the ObjectBrowser or ConstantEditor
controllers and when a new sys_template record is created.
b) Tag-based cache clearing in group 'pages' is performed by the
DataHandler when a TypoScript template is edited via
"Edit the whole template record" button.
Note: This is because the edit functionality is using
the plain record_edit FromEngine controller which means
EXT:tstemplate controllers only act as proxy here.

Note that both cases are wrong for sys_template records:

  • Case a) flushes too many caches:
    The DataHandler cache command 'all' flushes TCA, ext_localconf and
    Dependency Injection caches – since #75581 even opcache caches.
    All these (performance relevant) caches are never influenced by
    TypoScript and must not be flushed in production systems
    (results in slow responses due to cache rebuilds).
  • Case b) flushes too few caches:
    A sys_template record influences (in 99.9% cases) the page tree.
    By flushing the record via DataHandler tag flushed there
    are two caches being flushed: * pageId_[pidOfSysTemplateRecord] * sys_template_[uidOfSysTemplateRecord] * sys_template
    Non of these tags are assigned to page caches that rely on this
    sys_template record.

There are two options to consolidate cache clearing:

  • Use DataHandler tag-based flushing as in case b).
    The drawback: generates a lot of cache tags which
    are then flushed very rarely.
  • Flush the 'pages' cache group in both cases. This variant
    flushes a bit too much (of course, tags are more precise),
    as pages which did not rely on a currently modified
    sys_template record are flushed as well.

This change implements the latter option as we think the drawbacks of
flushing a bit too much is better than the drawback of generating a
ton of cache tags.
As all cases where the cache command 'all' was used, already modify
sys_template though DataHandler processing, we can remove the previous
cache commands and move the flush logic for all cases into a hook that
is triggered by the DataHandler when records are being created/changed.

Releases: master
Resolves: #89280
Change-Id: I4b705398634048ccf9fb7fe53acf2eb15fa55562
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/61834
Reviewed-by: Benni Mack <>
Reviewed-by: Daniel Goerz <>
Reviewed-by: Susanne Moog <>
Tested-by: TYPO3com <>
Tested-by: Benni Mack <>
Tested-by: Susanne Moog <>

History

#1 Updated by Gerrit Code Review about 2 months ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/61834

#2 Updated by Gerrit Code Review about 2 months ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/61834

#3 Updated by Benjamin Franzke 22 days ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

Also available in: Atom PDF