← Back to blog

11 Jan 2026

Varnish + Magento: headers that actually matter in production

Small headers, big cache differences.

In Magento, cache hit depends on specific headers:

- `X-Magento-Tags`
- `X-Magento-Cache-Control`
- `X-Magento-Vary`

When a module adds extra headers, Varnish treats the request as different.

Operational tips:
- Normalize headers with `req.http` in VCL.
- Avoid `Set-Cookie` on public pages.
- Review HTML `Cache-Control`.

In incidents, first check if HTML has `X-Magento-Cache-Debug: HIT`.
If not, the issue isn’t “more hardware”: it’s cache misconfiguration.

Common errors:
- `Vary` too long.
- Inconsistent `X-Forwarded-Proto` between Cloud and Varnish.
- Tracking cookies that invalidate full cache.

In Magento, the problem is often a marketing header. Remove it and hit rate jumps without infra changes.

Comments

I am not a robot
reCAPTCHA Privacy · Terms

Related

Recommended reads

Magento 2 at peak traffic: how to avoid lock storms during reindex

Read

Magento 2: how to read the checkout profiler without getting lost

Read

Redis in Magento: 5 common mistakes that break performance

Read