Woocommerce caches cart (Combined with W3 Total Cache)

I’ve experienced a weird issue on a site using WordPress + Woocommerce recenty. The site uses W3 Total Cache for page cache and browser cache and although i’ve set the woocommerce_cart_items cookie in the rejected list for page cache, the front page is beeing cached .
As a result i’ve issues with the cart ,empty on front page as is served as static, in other shop pages are regenerated and everything is fine.
To my understanding, pages are supposed to be cached if the cookie woocommerce_cart_items is missing ( so we have a guest customer browsing ), and after a product is added in the cart, woocommerce created a session and the cookie is stored so next time the frontpage is called it’s beeing regenerated and not served as static, is that right?
Is there a way to ensure this functionality?

Is this affected depending on the caching option selected (disk, apcu …)? if i decide to use redis for page cache , which is the best way to exclude such things from beeing cached?


Source: stackoverflow-php

JSP doesn’t show cookie for the first time

I set a cookie in javascript, not in controller and I want to check if that cookie exists in JSP. My cookie is set, but I have to reload the page manually in order to see it in jsp. I did reload method in javascript, but I still have to reload page once more.

JSP:
getting cookie: ${cookie['_sYrV'] } or ${cookie._sYrV }

Javascript:

set_cookie("name","value", 1);
window.onload = function () {
    if (!localStorage.reloadOnce) {
        localStorage.setItem("reloadOnce", "true");
        window.location.reload();
    }
}

var set_cookie = function(name, value, day) {
    var d = new Date();
    d.setTime(d.getTime() + (day * 24 * 60 * 60 * 1000));
    var expires = "expires=" + d.toUTCString();
    document.cookie = name + "=" + value + ";" + expires + ";path=/";
};

What should I do in order to see the cookie in jsp without reloading the page manually?


Source: stackoverflow-javascript