Issue Feature New Orphaned Good first issue

#106619Allow fine-grained control of Cache-Control headers

Christian Spoo 04/25/25, 13:59 updated 04/25/25, 14:01

Description

If config.sendCacheHeaders == 1, TSFE currently supports two possible values for the Cache-Control header, depending on whether the rendered response is cacheable or not.

If the response is not cacheable, belongs to a workspace or there is an active BE session, TSFE outputs Cache-Control: private, no-store. However, if the response is cacheable, only the calculated lifetime of the page is considered (as calculated by CacheLifetimeCalculator) and then hardwired Cache-Control: max-age=<lifetime> (or, from TYPO3 13, an additional s-maxage if needed).

There is no way to set additional flags for Cache-Control or to influence this process globally in any other way. However, for using TYPO3 behind a CDN, it would be great if we could append additional options to the generated Cache-Control header, depending on whether the response is cacheable or not. The most important options here would be, for example, stale-if-error and stale-while-revalidate, which can control more precisely how long the CDN may continue to deliver a cacheable response from TYPO3 if, for example, TYPO3 is briefly unavailable.

I have no concrete idea how this could be elegantly designed in TS – one possible idea would be, for example, to do this via additional fields in config. So far we have solved the problem using a PSR-15 middleware that rewrites the header after the rendering process, but I think a proper solution would be much better.

Reviews 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
[FEATURE] Allow fine-grained control of Cache-Control headers Resolves: #106619 Releases: main