1

One thing I don't understand about Varnish for M2 is how it will work with prices. Especially since M2 is meant for B2B, there could be customer groups with different prices. So when user 1 (customer group A) visits the page he will get $10 for product A but user 2 (customer group B) will get $20 for product A.

Is the price block automatically hole punched with Varnish for M2?

2

Is the price block automatically hole punched with Varnish for M2?

No.

there could be customer groups with different prices

Magento uses X-Magento-Vary cookie to "tag" different versions of the same page. Then Varnish hashes response based on that cookie. This allows actually storing several full page cache versions for the same product (each, for different customer group, language selections, etc.)

| improve this answer | |
  • Danila right answer. varnish only use for the full-page cache. @hardy123480 see inviqa.com/blog/how-full-page-cache-works-magento-2 for more details . – Amit Bera Jun 6 at 8:02
  • 1
    I never said only. Varnish is the go to solution for Magento 2 caching for the very fact that it can cache blocks with different cache lifetime. You might have a page that is not cached in full, but only a specific block on it is cached. – Danila Vershinin Jun 6 at 8:04
  • I understand, thank you. X-Magento-Vary is this cookie set automatically for different full page cache versions like customer group, etc? Or how would you set this up? Is this also true for the built in cache? And what about prices per customer? E.g. customer A has different price than customer B (both in the same group)? – hardy123480 Jun 6 at 8:13
  • X-Magento-Vary more or less represents a state. So when you, e.g. just visit a Magento 2 website, it will not be set. It will be set upon login or e.g. changing currency. Login under different customer groups will send a different vary header. You don't need to do anything special about it, Magento will be the one sending it automatically, and Varnish will "hash" on it, meaning different hash results in a separate cache entity. In a standard setup, no actions required, it will "just work". I don't think that built-in cache has anything to do with X-Magento-Vary. – Danila Vershinin Jun 6 at 9:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.