We need the listener to rewrite s-maxage before the store decision happens, so PRE_STORE is too late. the best option i can see is to have events around HttpCache::forward. changing the caching rules in POST_FORWARD should be the right spot to get the response cached. while we are at it, we should also do a PRE_FORWARD to allow users to modify the request before giving it to symfony if they want to.
to validate: does the control flow look the same in older symfony versions?
As discussed in https://github.com/sulu/sulu/issues/7441, the CustomTtlListener only gets active if s-maxage is > 0.
https://github.com/symfony/symfony/blob/04f9e6dc07cc228fb3023579c0a63a6ae06a4674/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php#L408-L410 decides whether to call
store
at all.We need the listener to rewrite s-maxage before the store decision happens, so PRE_STORE is too late. the best option i can see is to have events around
HttpCache::forward
. changing the caching rules in POST_FORWARD should be the right spot to get the response cached. while we are at it, we should also do a PRE_FORWARD to allow users to modify the request before giving it to symfony if they want to.to validate: does the control flow look the same in older symfony versions?