• Resolved yabdali

    (@yabdali)


    Hi,

    I am experiencing an issue where the Caching option (Easy Section) gets toggled off automatically. When I toggle it on and come back after few hours or a day I see that it got toggled off (Caching Off)!
    I don’t have page caching plugins except this. I use opcache, Autoptimize and JS Async if this makes any difference. But those are not causing any issues! I have tried other plugins in the past and didn’t face such strange behavior from any of the plugins. Can you please advise?? Thanks in advance…

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter yabdali

    (@yabdali)

    Some info from the debug log, could it be because I have a snippet in the functions that intercepts cache and disable it for logged users?? The reason I had this done in the past as I found that some pages get cached with logged user info and get indexed by Google!

    20:37:49 102 / wpsc_get_auth_cookies: cookies detected: wordpress_logged_in_abcd_xxxxx
    20:37:49 102 / wpsc_is_caching_user_disabled: true because logged in
    20:37:49 102 / Caching disabled for logged in users on settings page.
    20:37:49 102 / Supercache Late Init: add wp_cache_serve_cache_file to init
    20:37:49 102 / Supercache Late Loader running on init
    20:37:49 102 / ACCEPT: text/html
    20:37:49 102 / wp_cache_get_cookies_values: Login/postpass cookie detected
    20:37:49 102 / wp_cache_get_cookies_values: return: xxxabcd
    20:37:49 102 / supercache dir: ABSPATH/wp-content/cache/supercache/www.capitano.om/
    20:37:49 102 / No Super Cache file found for current URL: ABSPATH/wp-content/cache/supercache/www.xyz.com/index-https.html
    20:37:49 102 / ***********************************************************************************
    20:37:49 102 / * An extra output buffer has been detected. Check your plugins, themes, *
    20:37:49 102 / * mu-plugins, and other custom code as this may interfere with caching. *
    20:37:49 102 / * Late init is enabled. This allows third-party code to run before WP Super Cache *
    20:37:49 102 / * sets up an output buffer. That code may have set up the output buffer. *
    20:37:49 102 / ***********************************************************************************
    20:37:49 102 / In WP Cache Phase 2
    20:37:49 102 / Setting up WordPress actions
    20:37:49 102 / Created output buffer
    20:37:49 102 / wp_cache_get_cookies_values: cached: abcd_123_xxx
    20:37:49 102 / wp_cache_replace_line: changing line $cache_enabled = true; to *$cache_enabled = false;*
    20:37:49 102 / wp_cache_replace_line: writing to ABSPATH/wp-content/cache/123_xyz_xxxx.php
    20:37:49 102 / wp_cache_replace_line: moved ABSPATH/wp-content/cache/123_xyz_xxxx.php to ABSPATH/wp-content/wp-cache-config.php
    20:37:49 102 / wp_cache_disable: disable cache
    20:37:50 102 / DONOTCACHEPAGE defined. Caching disabled.
    20:37:50 102 / wp_cache_maybe_dynamic: returned $buffer
    function prevent_cache_for_logged_in_users() {
    if ( is_user_logged_in() ) {
    // Prevent caching by setting the necessary headers
    nocache_headers();

    // If using a caching plugin like W3 Total Cache or WP Super Cache, set their specific headers
    if ( defined( 'DONOTCACHEPAGE' ) === false ) {
    define( 'DONOTCACHEPAGE', true );
    }

    // For other caching plugins, setting the DONOTCACHEPAGE constant is usually enough
    // However, if you use a caching plugin that requires specific headers, add them here:
    // For WP Super Cache:
    if ( function_exists( 'wp_cache_disable' ) ) {
    wp_cache_disable();
    }

    // For W3 Total Cache:
    if ( function_exists( 'w3tc_pgcache_flush' ) ) {
    w3tc_pgcache_flush();
    }
    }
    }
    add_action( 'template_redirect', 'prevent_cache_for_logged_in_users' );

    function add_noindex_nofollow_to_headers() {
    if ( is_user_logged_in() ) {
    echo '<meta name="robots" content="noindex, nofollow, nosnippet, noarchive">';
    }
    }
    add_action( 'wp_head', 'add_noindex_nofollow_to_headers' );
    • This reply was modified 2 months, 2 weeks ago by yabdali.
    • This reply was modified 2 months, 2 weeks ago by yabdali.
    Plugin Support Alin (a11n)

    (@alinclamba)

    Hi @yabdali,

    Based on the debug log and the custom snippet you provided, it seems like the function that prevents caching for logged-in users is likely contributing to the issue where the caching option is being toggled off automatically.

    Did you know that WP Super Cache has a built-in feature that can handle this automatically? You can enable the “Disable caching for logged in visitors” option in the plugin’s settings under the Advanced tab, which will prevent caching for logged-in users without the need for custom code. This should ensure that no sensitive information is cached or indexed by search engines

    However, if you still prefer to use custom code or need it for specific cases, I recommend reviewing the snippet to ensure it only disables caching where necessary, rather than affecting the entire caching functionality.

    Let us know if this helps.

    Plugin Support Stef (a11n)

    (@erania-pinnera)

    Hey @yabdali,

    Do you have updates about that, do you still need help? We usually close inactive threads after one week of no movement, but we want to make sure we’re all set before marking it as solved. Thanks!

    Thread Starter yabdali

    (@yabdali)

    I am good, I realized the issue was caused by the code snippet I shared earlier. However, I had turned off your plugin as it was causing issues with Woocommerce, it was not working properly when clicking add to cart and it could be due to ajax support. I use Booking Activities plugin, the add to cart is name book and its supposed to redirect the customer to the product page once the button is clicked on the shop archives page but instead it doesn’t get redirected and nothing get even added to the cart. Therefore, I had to turn it off since I couldn’t find good documentation on how to configure it.

    Plugin Support lastsplash (a11n)

    (@lastsplash)

    Hi @yabdali

    I recommend reaching out to the developers of “Booking Activities” to see if they can help troubleshoot the issue. We aren’t able to assist with configuring third-party plugins.

    I’m going to mark this thread as resolved for now, but if you have issues with WP Super Cache in the future, feel free to open a new thread.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.