Date insert tag causes caching issues
Affected version(s)
5.3.13
Description
Having the following cache settings:
And a
{{date::Y}} on the page results in the follwing HTTP response:
HTTP/2 200
date: Thu, 29 Aug 2024 22:14:11 GMT
…
cache-control: public, s-maxage=86400
age: 0
contao-cache: miss/store
expires: Tue, 31 Dec 2024 22:59:59 GMT
The expires header is wrong and causes the response to get cached in the browser until the end of the year.
@Toflar /cc
I think that's more something for @aschempp because that's the ResponseCacheStrategy he contributed to that should make sure that the lowest Expires header is considered and not the highest.
My guess would be that cache time 0 is merged incorrectly because it is probably interpreted as “not set” or so. But I did not debug it yet.
I have found the issue and am working on a solution. The problem is that our page sets maxage and s-maxage Cache-Control headers, but the insert tag controller sets Expires. These are currently not merged by the Symfony ResponseCacheStrategy.
I'll open a PR for Symfony asap. We could also change our implementation to use maxage, but I would prefer not to because it is also supposed to work like this 😅
see https://github.com/symfony/symfony/pull/58376 for the Symfony fix. It should be fixed in Contao 5 once this makes it into Symfony 6. I might need to do another Symfony PR though because of upstream merging issues.
https://github.com/symfony/symfony/pull/58376 has been merged - has this issue been fixed?