1

Preconditions

1.Magento 2.3.4

2.Must Varnish Enable

Steps to reproduce

1)Do not add any product to the cart.

2)Directly go to https://www.sample.domain/checkout/

3)Because No product in cart Redirect user to Cart page https://www.sample.domain/checkout/cart

4)Add any product in the cart.

5)Go to Checkout.

6)It will redirect you to the cart page because of the caching of step 3 in varnish.

Expected result

1)Do not add any product to the cart.

2)Directly go to https://www.sample.domain/checkout/

3)Because No product in cart Redirect user to Cart page https://www.sample.domain/checkout/cart

4)Add any product in the cart.

5)Go to Checkout.

6)It should allow the user to go to the cart when the product is available.

Actual result

Because of Varnish, It cache steps 2 and 3 redirection and next time when users come with the product at that time also it not allowing the user to go to the checkout page. So it should stop track of that redirection by varnish.

2
  • Can you provide mode details. This does not seem to be happening on a fresh 2.3.4 version. Do you have other modules or have you made any changes to the checkout layout or templates? Are there any 3rd party modules that you're using that might affect this? – drew7721 Mar 13 '20 at 21:22
  • Also, if this is in fact an issue with the core code, I would suggest you open a ticket on github.com/magento/magento2/issues and provide the STR there so that this can be tested. But I would suggest testing this against a fresh unmodified version of the code and see if it persists. Then you might be able to see what is the exact cause for this enabling your custom code one module at a time. – drew7721 Mar 13 '20 at 21:24
1

Checkout and cart pages should never be cached in Varnish.

Look at the default.vcl config that M2 creates. Note this line.

    # Bypass shopping cart, checkout and search requests
    if (req.url ~ "/checkout" || req.url ~ "/catalogsearch") {
        return (pass);
    }

That means that the checkout and the search should never be cached in varnish.

Did you remove that from the .vcl file for your varnish server?

Make sure you use the default vcl for the correct varnish version and modify it as you need but without removing core conditions.

There is also a cache='false' attribute that you can set on blocks in the layout that will prevent caching and I believe that they are used in the cart and checkout.

So check your theme or customization since that might be causing this issue.


For instance see the layout file checkout_index_index.xml in the Checkout module. That should set a block named checkout.root and that block should have the attribute cacheable set to false.

layout for checkout

If a you have a custom module that changes this or if you made changes there make sure you did not remove that.

5
  • No, I have not remove anything from default.vcl file. I checked and find your suggested code inside that. – JACK Mar 13 '20 at 14:03
  • Check the updated answer and let me know if that does it. – drew7721 Mar 13 '20 at 21:31
  • thank you for your answer. But we used Magento default checkout. and the core file is untouched and not edited. – JACK Mar 14 '20 at 9:01
  • Any 3rd pary extensions? Is this happening on a blank M2 install? This is not a know issue. There must be something making changes to your code. Can't really tell you what unless you give more details. – drew7721 Mar 14 '20 at 21:37
  • We do not use any 3rd party modules. This is happening with a black m2 installed. – JACK Mar 16 '20 at 6:33

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.