contao icon indicating copy to clipboard operation
contao copied to clipboard

Date insert tag causes caching issues

Open ausi opened this issue 1 year ago • 5 comments

Affected version(s)

5.3.13

Description

Having the following cache settings: Bildschirmfoto 2024-08-29 um 23 12 15 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.

ausi avatar Aug 29 '24 22:08 ausi

@Toflar /cc

leofeyer avatar Aug 30 '24 08:08 leofeyer

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.

Toflar avatar Aug 30 '24 08:08 Toflar

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.

ausi avatar Sep 05 '24 10:09 ausi

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 😅

aschempp avatar Sep 24 '24 07:09 aschempp

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.

aschempp avatar Sep 24 '24 13:09 aschempp

https://github.com/symfony/symfony/pull/58376 has been merged - has this issue been fixed?

fritzmg avatar May 07 '25 09:05 fritzmg