Mini cart optimize for caching plugins

Sorry, but shop created with Bricks Builder + Woocommerce is slow.
Generate first server response take about 2,5-3,2 second.
So we have to use some cache plugin.
If someone use cache plugin, mini cart may be cached with data.
I think there would be useful option to set empty mini cart and zero value for mini cart products count displayed into circle.
I would like to enable this option if I enable cache plugin.
For example mini cart products count, now into code is like below.

Products count:

<span class="cart-count"><?php echo absint( $cart_count ); ?></span>

better will be:

<span class="cart-count hide">0</span>

Cart amount:

<span class="cart-subtotal"><?php echo $subtotal; ?></span>

For cache enabled better will be:

<span class="cart-subtotal hide">0.00</span>

I cant find currency, but the final effect should be:

<span class="cart-subtotal"><span class="woocommerce-Price-amount amount"><bdi>0.00<span class="woocommerce-Price-currencySymbol">&euro;</span></bdi></span></span>

Mini cart is actualized after few miliseconds after page load.
But if cache contais for example 5 products into product count circle, user see first 5 and after milicecond browser change this to actual value.

1 Like

I agree, we built the Woocommerce store with Bricks and Server Response is really slow between 500-1500ms in our case. Where with the previous theme, it used to be less than 500ms!

We have the same server, so it’s definitely not the slow server issue.

I also see the same problem with Mini cart, after pages are cached.

@MarekKmiecik did you find a temporary solution for that? Can we somehow exclude this element in caching plugin?

I am currently trying to find the best caching plugin for Brick with Woocommerce that can speed up the site with a lot of dynamic data, especially product category pages. Currently switched to WP Fastest Cache.

Check out this topic:

Thanks, @parktechno. Do you know how can we exclude caching of mini cart element?

My solution is modify static cache html file. Cache plugin I use allow to use str_replace php function when static html cache file is created.

$string = preg_replace( '/<span class="cart-count">(\d+)<\/span>/', '<span class="cart-count hide">0</span>', $string );
$string = preg_replace( '/<span class="cart-subtotal"><span class="woocommerce-Price-amount amount"><bdi>(.*)<span class="woocommerce-Price-currencySymbol">(.*)<\/span><\/bdi><\/span><\/span>/', '<span class="cart-subtotal"><span class="woocommerce-Price-amount amount"><bdi>0.00<span class="woocommerce-Price-currencySymbol">&euro;</span></bdi></span></span>', $string);

It’s just about that show cart amount zero and products into cart count zero.
After page is loading script actualize mini cart.

1 Like