An Architect working on a headless Adobe Commerce project creates a new customer attribute named my_attribure. Based on the attribute value of the customer, the results of GraphQI queries are modified using a plugin. The frontend application is communicating with Adobe Commerce through Varnish by Fastly, which is already caching the queries that will be modified. The Adobe Commerce Fastly extension is installed, and no other modifications are made to the application.
Which steps should the Architect take to make sure the vcl_hash function of Varnish also considers the newly created attribute?
A)

B)

C)

Answer(s): B
Explanation:
Option B is the correct way to make sure the vcl_hash function of Varnish also considers the newly created attribute. The Architect should create a new module that depends on Magento_Fastly and declare a plugin for \Magento\Fastly\Model\Config::getVclSnippets() method. The plugin should add a new snippet to the result array with the type `recv' and the content `set req.http.my_attribute = req.http.X-Magento-Vary;'. This will append the value of the customer attribute to the hash key used by Varnish for caching. Option A is incorrect because it modifies the core file of Magento_Fastly module, which is not recommended and can cause issues during upgrades. Option C is incorrect because it uses the wrong type and content for the snippet, which will not affect the vcl_hash function.
Reference:
https://devdocs.magento.com/cloud/cdn/fastly-vcl-bypass-to-origin.html According to the Adobe Commerce Developer Guide2, to make sure the vcl_hash function of Varnish also considers the newly created attribute, the Architect should use a plugin for Magento\Customer\Model\Context::getVaryString method and add the attribute value to the vary string. This will ensure that Varnish caches different versions of GraphQL queries based on the attribute value of the customer. Therefore, option B is correct. Option A is not correct because it does not affect the vcl_hash function. Option C is not correct because it does not use a plugin for the getVaryString method.
Reveal Solution Next Question