Guidance for cloudflare configuration for the shopping cart

Posted in: Newspaper
Post count: 162

We are using Cloudflare (Pro) and would like to cache the whole page except from the cookie part.

https://blog.cloudflare.com/ecommerce-best-practices/

Sadly this page rule is only available for Business and Enterprise users.

So, we would like to make use of the second best practice (i.e. Method 2: Populating via JavaScript / AJAX).

Is it please possible to provide us with the rules that we have to create so that the shopping basket is not cached?

Thank you.

Post count: 162

To make the question more specific:
With these two rules:
.ecode.gr/wp-json/*
.ecode.gr/wp-admin/*

Set to
Cache Level: Bypass

It seems to be working (when cache is set to ignore query string). The question is if we can make it even more specific than this.

Post count: 35449

Hi,
Unfortunately, I do not know exact if this can be made more exact then that, I will ask a developer and see if is possible. What I can do is to provide our guide for CDN -> https://forum.tagdiv.com/cloudflare-cdn/ but, I think that you already checked it.
After I will got an answer from developer I will let you know!
Thank you!

Post count: 162

Hi Calin!

These rules

(obviously with the bottom rule also active)

seem to be working fine, but with one exception:
When you are on the cart page and you remove an item from the cart this does not show on the cart include in the menu (top right)

If we can be more specific on the files that need to be bypassed from caching it may actually work.

Post count: 35449

Hi,
Please make a test and disable this option too -> https://i.imgur.com/v4MKqcY.png is possible to help.
Thank you!

Post count: 162

I did this, and it is still does not get updated. In carts that had history in them, but were abandoned, after deletion of the item the user also sees the past choices. I will post a video of the situation.

Post count: 162

Here is the video: https://1drv.ms/v/s!Akul2ygARwfdh5V5kkO9ycjQcun5mw?e=23j3NK

And here are the settings in function.php to optimise the performance of woo commerce.

/** Disable Ajax Call from WooCommerce on front page and posts*/
add_action( 'wp_enqueue_scripts', 'dequeue_woocommerce_cart_fragments', 11);
function dequeue_woocommerce_cart_fragments() {
if (is_front_page() || is_single() ) wp_dequeue_script('wc-cart-fragments');
}

/** Disable All WooCommerce Styles and Scripts Except Shop Pages*/
add_action( 'wp_enqueue_scripts', 'dequeue_woocommerce_styles_scripts', 99 );
function dequeue_woocommerce_styles_scripts() {
if ( function_exists( 'is_woocommerce' ) ) {
if ( ! is_woocommerce() && ! is_cart() && ! is_checkout() ) {
# Styles
wp_dequeue_style( 'woocommerce-general' );
wp_dequeue_style( 'woocommerce-layout' );
wp_dequeue_style( 'woocommerce-smallscreen' );
wp_dequeue_style( 'woocommerce_frontend_styles' );
wp_dequeue_style( 'woocommerce_fancybox_styles' );
wp_dequeue_style( 'woocommerce_chosen_styles' );
wp_dequeue_style( 'woocommerce_prettyPhoto_css' );
# Scripts
wp_dequeue_script( 'wc_price_slider' );
wp_dequeue_script( 'wc-single-product' );
wp_dequeue_script( 'wc-add-to-cart' );
wp_dequeue_script( 'wc-cart-fragments' );
wp_dequeue_script( 'wc-checkout' );
wp_dequeue_script( 'wc-add-to-cart-variation' );
wp_dequeue_script( 'wc-single-product' );
wp_dequeue_script( 'wc-cart' );
wp_dequeue_script( 'wc-chosen' );
wp_dequeue_script( 'woocommerce' );
wp_dequeue_script( 'prettyPhoto' );
wp_dequeue_script( 'prettyPhoto-init' );
wp_dequeue_script( 'jquery-blockui' );
wp_dequeue_script( 'jquery-placeholder' );
wp_dequeue_script( 'fancybox' );
wp_dequeue_script( 'jqueryui' );
}
}
}

But the behaviour is the same, regardless of them being present or not.

Post count: 35449

Hi,
About the code that you added, please remove those related to cart, in this way you can be sure that will not interfere.
From what I seen on your record and from the tests that I made it is like the cart is not updated only if you refresh the page.
Also, when you are logged the problem happens? If not it can also be from some settings from the cache plugin. It may be from the siteground optimizer settings.
Thank you!

Post count: 162

Yes Calin, obviously it has to do with the settings. This is why I asked you so that your developers can tell you which js, css, php pages calls are involved so that I can exclude them from both cloudflare and the optimizer.
Can we have this list please?
Thank you

Post count: 35449

Hi,
I made a request to one of our developers and I hope I will got soon an answer!
Thank you!

Viewing 10 posts - 1 through 10 (of 10 total)
The forum ‘Newspaper’ is closed to new topics and replies.