Skip to content

[Cache] "vary" prop from Cache attribute doesn't work when inferring Locale from Accept-Language #58663

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
cdaguerre opened this issue Oct 25, 2024 · 2 comments

Comments

@cdaguerre
Copy link

Symfony version(s) affected

7.1.0

Description

Cache attribute's vary property is silently ignored with following config:

framework:
  set_locale_from_accept_language: true

And following controller

use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpKernel\Attribute\Cache;

class SomeController
{
    #[Cache(smaxage: 3600, vary: ['X-Some-Header'])]
    public function index(): Response
    {
         return new JsonResponse("OK");
    }
}

The LocaleListener adds an attribute to the request that is used by the ResponseListener to add a Vary: Accept-Language header.
However, this occurs before the CacheAttributeListener, which doesn't take the attribute's vary property into account if there is already a Vary header on the response.

Is this expected?

How to reproduce

See above.

Possible Solution

No response

Additional Context

No response

@carsonbot
Copy link

Hey, thanks for your report!
There has not been a lot of activity here for a while. Is this bug still relevant? Have you managed to find a workaround?

@carsonbot
Copy link

Just a quick reminder to make a comment on this. If I don't hear anything I'll close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants
@xabbuh @cdaguerre @carsonbot and others