I’m running into a bit of a strange (to me) situation, and would appreciate help. I’m not even entirely sure that this is the right forum to ask for help, so pointers somewhere else would be great if there’s a better place.
I have WP with WooCommerce installed, and it’s been working great for a couple of years. In the last little while (month? – not quite sure when this started), the WooCommerce cart widget has not been updating when a customer adds a product to their cart.
This can be seen on the following page (https://adventuretaco.com/product/tacoma-to-tundra-hard-brake-line-kit/) by
-
Open browser developer tools and switch to the Networking tab
-
Click the Add to Cart button
Edit/update: ==> Page reloads as expected -
Watch the “cart” widget on the right and note that it does not update
-
As the page is reloading and loading all resources, watch the browser dev tools, and look for the request to https://adventuretaco.com/?wc-ajax=get_refreshed_fragments
-
The result is that it is always cut off after exactly 5 seconds. (or 5.01/5.02 seconds).
REPRO 2:
- Open browser developer tools and switch to the Networking tab
- browse to https://adventuretaco.com/minimal
- watch the browser dev tools, and look for the request to https://adventuretaco.com/?wc-ajax=get_refreshed_fragments
Because the response doesn’t come back in that time, the cart never updates. However, direct requests (non-AJAX) to that URL do return correctly (after more than 5 seconds) with the correct cart data.
Why is this request getting cut off? The answer might be in the browser dev tool data, but I don’t see it (or know what I’m looking for).
I’m not sure if it matters, but the backend is linux/nginx.
Thanks!
2
Answers
So, I don't have a "real" answer to this, but in case others have the same issue and stumble on this question that I asked, my solution was not what I expected, but more than I hoped for.
I moved from Azure (where I was running Wordpress on Linux with Flexible MySQL) to AWS (where I'm running a Lightsail WP instance and a Lightsail MySQL database).
Cost is about the same per month - as of this answer, in the $20 range - but holy smokes is the AWS platform so much more performant.
Not just this call for the WC cart, but everything on my site is orders of magnitude faster. Almost feels like I don't need a caching plugin, though I continue to use one as it's clearly good practice.
Migration was easy as well - just used MySql Workbench to copy over the database, and then FTP to grab the wp-content directory. Was up and running in less than a few hours, and it was a simple DNS change to point the domain to the new IPs.
Hope this helps anyone else considering perf on Azure.
As noted by the comments on the first question, the cancellation doesn’t timeout, it get’s cancelled, which means, that we can safely assume, that it happens on the client-side.
So I searched for somewhere this timeout is set on the client side, and as of woocommerce 8.3.0, in
wp-content/plugins/woocommerce/includes/class-wc-frontend-scripts.php
you have a method calledget_script_data($handle)
, which includes a case forwc-cart-fragments
:Which has
'request_timeout' => 5000,
Be aware that this is probably a performance parameter set by woocommerce intentionally, so the best solution is still to fix your site’s responsiveness. However, if you want to change it, I have two suggestions:
return apply_filters('woocommerce_get_script_data', $params, $handle);
, so you can add a filter like this: