I'm trying to submit an extension for Magento 2.4 but can't pass the "Varnish Test" stage because of the cache that can't be set up on some pages (simple-product and category):
"Expected HIT on the second page load.": ...
"Expected HIT on the second page load after product price update.": ...
I suppose in my case this error is due to the fact that I create cookies from my module code which could prevent the activation of the Varnish cache.
I have created two Observers on "controller_front_send_response_before" and "controller_action_postdispatch" events in which I create cookies with product information. I then retrieve and process this data from the front in JavaScript.
For my local tests, I have activated the varnish cache. When I request a product page or a category I can see the header "X-Magento-Cache-Debug: HIT".
Do you know if there are any special recommendations to follow regarding the creation of cookies in Magento 2 while allowing Varnish caching?
Thank you in advance,