Caching issue due to recently viewed products

This topic has 2 replies, 2 voices, and was last updated 11 months, 3 weeks ago ago by Rose Tyler

  • Avatar: fabio_vito
    Fabio
    Participant
    May 2, 2023 at 09:35

    Dear Support,
    I am contacting you after having discussed already with Woocommerce and SGOptimizer support team.
    Since a while my website product pages cannot be cached. This is due to the fact that the caching engine cannot be trigger is there are cookies in the header.
    Apparently cookies are added to the header by Woocommerce, function woocommerce_recently_viewed. This function adds cookies to the header only when the widget “recently viewed products” is active. However, on my website this widget is not active, never was and I do no plan to activate it.

    Still, cookies are added to the header. Woocommerce states that most probably my theme does it behind the scene.

    Could you please help me to deactivate this function if triggered by the theme? alternatively could you please give me a code that i could add to functions.php, in order to stop the function to pass cookies to the header?

    Thanks in advance.

    F.

    Please, contact administrator
    for this information.
    1 Answer
    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    May 2, 2023 at 13:14

    Dear Fabio,

    Thank you for contacting us and for using XStore.

    Such cookies could be written to your headers because on one of next reasons:
    1/ You have somewhere across the web-site Products element with Recently viewed products set for its Data
    2/ You have Sales booster popup displayed (fake sales notification)
    3/ Extra plugin writes such cookies for its reason

    We can recommend you try next solution by adding the next code to your child-theme/functions.php

    add_action('wp', function() {
        remove_action( 'template_redirect', 'et_wc_track_product_view', 20 );
    }, 70);

    We can recommend you check from an incognito window or clear your browser cookies and check in non-incognito.

    Otherwise, if it does not help, please, check one by one plugins you have installed and activated.

    Kind Regards,
    8theme team

  • Viewing 2 results - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.Log in/Sign up

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.