#107062CSP handling disables Caching
Description
As soon as any kind of Content Security Policy handling is configured, TSFE adds the http header ‘Cache-Control: private, no-store’ (line 2426, as of v. 12.4.33) to the rendered page. https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/ContentSecurityPolicy/Index.html#notes-about-nonces-and-caching mentions this behaviour. This leads (at least in one of my projects) to a situation where no pages are cached within our CDN.
From my point of view, the basic problem is that \TYPO3\CMS\Frontend\Middleware\ContentSecurityPolicyHeaders.php adds the attribute ‘nonce’ to the request, even if there is no CSP mutation requiring nonces. I would like to propose a change in that class, so that the ‘nonce’ attribute is only added to the request, if any of the CSP mutations make use of such features.
I’ve written a (sketchy) patch that solves the problem within my project (see the attached file) and would like to suggest an equivalent change in the core.
Thanks & cheers
Sven