'Exclude add product bottom action in WordPress shopping cart from varnish cache

When press plus bottom for add more than 1 of product to shopping cart on wordpress, Finally product add to cart after one minute, but I see this error:

Request URL: https://12345.com/cart/

Request Method: POST

Status Code: 503 Backend fetch failed

x-requested-with: XMLHttpRequest

in my vcl I add this value but not work:

# The code below makes sure the AJAX "add to cart" function works
   set req.url = regsub(req.url, "add-to-cart=\d+_\d+&", "");

 # Do not cache AJAX requests.
   if (req.http.X-Requested-With == "XMLHttpRequest") {
       return(pass);
   }

 # Post requests will not be cached
   if (req.http.Authorization || req.method == "POST") {
       return (pass);
   }

Related images links:

https://i.postimg.cc/hGPTFx0S/header.png

https://i.postimg.cc/BbQ7ztwk/cookies.png



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source