#72703Flash message caching has changed in TYPO3 7.3
Description
Flash messages rendered by EXT:fluid VH are cached and rendered from cache on page access. This was not the case before TYPO3 7.3 and is not the case when using TYPO3 6.2.
Example
User creates an object, a flash message is added and the user is redirected to the list view.
The flash message will be cached and displayed to any user until the cache of the page is flushed somehow.
Previously the page cache was disabled whenever the flash messages VH was used within a cached plugin.
Cause of this is a removed no cache config in the flash message VH, see marked line:
This behavior change is undocumented and should be considered breaking.
LinksReviews 0
No change resolves or names this issue in its commit message, and no comment links one.
Fix this issue
Start the commit message of your patch with this. Add what the patch does, and the versions it goes to in "Releases:". How to create a patch
- Commit message
-
[BUGFIX] Flash message caching has changed in TYPO3 7.3 Resolves: #72703 Releases: main
Related issues 1
History 11
-
Riccardo De Contardi commented and changed status
NewNeeds Feedback <span data-processor="relativetime" data-value="2016-05-14T15:57:26+00:00" > 05/14/16, 15:57 </span> -
Felix Nagel commented <span data-processor="relativetime" data-value="2016-05-20T00:53:26+00:00" > 05/20/16, 00:53 </span>
Hey, I’ve tested this in TYPO3 7.6.7 and 8.1.0. It’s still an issue.
-
Riccardo De Contardi changed status
Needs FeedbackNew <span data-processor="relativetime" data-value="2016-07-18T16:37:32+00:00" > 07/18/16, 16:37 </span> -
ondro no-lastname-given commented and changed description <span data-processor="relativetime" data-value="2016-11-28T11:19:54+00:00" > 11/28/16, 11:19 </span>
Can confirm
same behaviour on Typo3 v 7.6.11 -
Felix Nagel commented and changed description <span data-processor="relativetime" data-value="2016-11-28T11:34:24+00:00" > 11/28/16, 11:34 </span>
@ondro no-lastname-given
Please do NOT remove useful information from the description.
-
Susanne Moog changed Sprint Focus On Location Sprint <span data-processor="relativetime" data-value="2018-10-25T11:46:25+00:00" > 10/25/18, 11:46 </span>
-
Susanne Moog changed Sprint Focus
On Location Sprint<span data-processor="relativetime" data-value="2020-01-12T12:06:38+00:00" > 01/12/20, 12:06 </span> -
Susanne Moog changed category <span data-processor="relativetime" data-value="2020-03-25T17:47:51+00:00" > 03/25/20, 17:47 </span>
-
Stefan Froemken commented <span data-processor="relativetime" data-value="2022-03-11T07:28:53+00:00" > 03/11/22, 07:28 </span>
As persistence.enableAutomaticCacheClearing is activated by default you only need to add TCEMAIN.clearCacheCmd = [pagesWithYourPlugin] into PageTSConfig of your storages pages.
Extbase itself contains mechanisms in CacheService to interprete this PageTSConfig and clears cache for you.The old solution with $GLOBALS[‘TSFE’]->no_cache = 1 will only render the page uncached, but IMO the old page cache is still valid. So if you or another visits the list page again, your new created record is still missing.
-
Stefan Froemken commented <span data-processor="relativetime" data-value="2026-11-02T14:54:32+00:00" > 11/02/26, 14:54 </span>
A follow-up to my comment from 2022. Clearing the page cache after saving still works, either through Extbase’s automatic cache clearing or
TCEMAIN.clearCacheCmd. The new record shows up. The flash message problem remains, though.After the redirect the first request renders the list page uncached. This rendering picks up the flash message from the visitor’s session. The resulting HTML is written to
cache_pagesincluding the message and is delivered to all following visitors with the same usergroups. We reproduced this on 13.4: another user of the same group saw the message of the author.Since TYPO3 13 this can be solved in the target action. The frontend request carries a mutable
CacheInstructionin the attributefrontend.cache.instruction.TypoScriptFrontendController::generatePage_postProcessing()checksisCachingAllowed()after the content has been rendered and right before the page is written to the cache. So disabling the cache from within a cached Extbase action keeps exactly this one response out of the page cache:if ($this->getFlashMessageQueue()->getAllMessages() !== []) { $this->request->getAttribute('frontend.cache.instruction')?->disableCache( 'EXT:my_ext: Flash messages must not be cached', ); }Tested on 13.4.35 with curl and a look into the database. An anonymous visitor sees the message once. That response is not stored and
cache_pagescontains no entry with the message. The following requests are cached as usual. With logged-in users the author sees the message once and another user of the same group never sees it.Some notes:
- Run the check before the template is rendered.
<f:flashMessages />flushes the queue, so the check is always false afterwards. - The redirecting action must add the message to the queue of the target plugin (
extbase.flashmessages.<pluginNamespace>). That is the queue the ViewHelper reads. - The target page must really be rendered uncached after saving. You still need
TCEMAIN.clearCacheCmdor the cache tags<table>/<table>_<uid>which DataHandler and Extbase flush. Otherwise the old page comes from cache and your action is not executed at all. - This only matters for cached plugins (USER). USER_INT output is not cached anyway.
disableCache()requires a non-empty reason and throws an exception otherwise.- TYPO3 13+ only. The
frontend.cache.instructionattribute does not exist in older versions.
- Run the check before the template is rendered.
-
Helmut Hummel changed Related to #63453 <span data-processor="relativetime" data-value="2026-11-03T08:40:14+00:00" > 11/03/26, 08:40 </span>
Hi. does this issue still occur in 7.6.6 or the latest master? Thank you!