#107499ActionController redirectToUri cache control headers are overritten
Description
Hi,
My action controller action method returns :
return $this->redirectToUri("https://xxxx",0,301)
->withHeader('Cache-control', 'max-age=86400')
->withHeader('X-Test', 'test');
The browser does receive the 301 but only the X-Test header is present, cache control headers get replaced.
location: https://xxxx Cache-control: no-cache, no-store X-Test: test
My goal here is to have the reverse proxy in front of my Typo3 cache the response.
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.
History 5
-
Garvin Hicking commented and changed status
NewNeeds Feedback 09/20/25, 18:43 -
Rémi Payette commented 09/22/25, 19:30
Thanks for the hint.
PropagageResponseException doesn’t help but its parent ImmediateResponseException does.
but https://api.typo3.org/main/classes/TYPO3-CMS-Core-Http-ImmediateResponseException.html
>It should not be thrown by controllers, those should usually throw a PropagateResponseException instead, allowing outer middlewares to further process the response.It gets the job done for now but it feel more like a hack than a solution.
-
Garvin Hicking commented 09/24/25, 05:35
Yes, this is a hack and we hopefully can figure out a cleaner approach at some point. :-/
Would it be on to close this issue for now? I believe a “feature” issue for this exists already but I could not research it.
-
Rémi Payette commented 09/24/25, 15:06
I can’t change the ticket status myself but yes, you can close this issue.
-
Garvin Hicking commented and changed status
Needs FeedbackClosed 09/25/25, 19:10thx!
Not a full investigation, just a thought: The problem likely is the middleware bubbling happening to the response.
If you want to be the “ultimate” response, you might want to use the PropagageResponseException. Granted it is awkward, but would allow you to have the final say in the redirect. See https://api.typo3.org/main/classes/TYPO3-CMS-Core-Http-PropagateResponseException.html
Would that help?