Skip to content

Missing Vary-Cookie makes pages uncachable (for Varnish) #40272

@rommelfreddy

Description

@rommelfreddy

Preconditions and environment

  • Magento version: >= 2.4.8
  • not logged in customer

Steps to reproduce

Just setup Varnish with the default-configurations

Expected result

Cacheable Pages, like CMS, Catalog and so on, should be cached and stored in the Varnish-Cache

Actual result

Magento will always make the response uncachable by calling Magento\Framework\App\Response:: setNoCacheHeaders

Additional information

In commit d6c05bd, logic was added to make the response uncacheable if the Vary cookie does not match the actual (generated) vary string.

While this makes sense in principle, it also causes all pages to become uncacheable whenever no Vary cookie is set — which is always the case on the very first request.

Additionally, this situation also occurs when Varnish requests the backend without sending the Vary cookie. As a result, this bug affects all ESI requests as well.

This issue should be treated with high priority, as it effectively prevents full-page caching with Varnish from functioning correctly.


For anyone encountering this problem, I’ve created a temporary patch until an official fix is released: patch

Please use this patch with care and test your application thoroughly.

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

Labels

Issue: needs updateAdditional information is require, waiting for responseReported on 2.4.8Indicates original Magento version for the Issue report.Triage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject it

Type

No type

Projects

Status

Needs Update

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions