FriendsOfSymfony / FOSHttpCache

Integrate your PHP application with your HTTP caching proxy
https://foshttpcache.readthedocs.io
Other
353 stars 60 forks source link

custom ttl should work even without s-maxage #576

Open dbu opened 4 months ago

dbu commented 4 months ago

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?