Skip to content

Multi-store cache conflict with Varnish #38483

Open
@br33f

Description

@br33f

Preconditions and environment

Magento 2.4.3-p2 and 2.4.6 for sure. Perhaps other versions too.

  1. There must be at least two store views configured.
    image
  2. Multi-store must be set up on a single domain (using cookie)
  3. Full Page Cache > Caching application should be set to Varnish.
    image
  4. Varnish configuration is set according to the configuration generated with "Export VCL for Varnish 6"

Steps to reproduce

  1. Enter a page (let's call it X) that is available on both store views (and URL is the same)
  2. Switch store to non-default (let's call it B)
  3. Clear all cache (including Varnish)
  4. Go to Developer tools and delete "X-Magento-Vary" cookie. Leave other cookies (store etc.) as it is.
  5. Refresh page
  6. Try to switch back to default store view (let's call it A)

Expected result

Store view switches back to default store view. The page shows content from store view A (default).

Actual result

You can not switch store view back to default store view on the page you visited.
It works fine on another pages. However this particular page X is being returned from Varnish which (because the lack of X-Magento-Vary cookie) cached store B contents as default (A) (without X-Magento-Vary cookie).

Even if you switch store view to default on another page and then navigate to Page X - store switcher will show invalid store and page content is still wrong.

Additional information

Varnish stores cache according to X-Magento-Vary cookie. If this cookie is missing - Varnish assumes that it is a default store view. However one can make a request without X-Magento-Vary cookie, but still with "store" cookie.
Magento does not validate that, it returns content for specified "store" - but Varnish caches it without X-Magento-Vary.

Then if you visit page with default store view (X-Magento-Vary cookie not present) - Varnish serves you with invalid store view page.

Release note

No response

Triage and priority

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: Other Developer ToolsComponent: PageCacheIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P2A defect with this priority could have functionality issues which are not to expectations.Progress: ready for devReported on 2.4.xIndicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branch

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions