Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Copy link
Copy link
Open
@cdaguerre

Description

@cdaguerre
Issue body actions

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.