WP Super Cache Dynamic Secret TAG visible on uncached first load

I am trying to utilise the dynamic caching features of WP Super Cache, but I’m having an issue and I can’t see how to fix it, currently, when my site loads for the first time, my secret key shows on front-end, when the user refreshes the page it will show the content

I found a similar issue on:
https://github.com/Automattic/wp-super-cache/issues/490

Example code:
https://github.com/Automattic/wp-super-cache/blob/master/plugins/dynamic-cache-test.php

Can you help me?

  • Louis
    • New Recruit

    Hi Kasia,

    Thanks for your help. Sadly, that doesn’t seem to affect the fact that on first load there is still the token appearing…

    Do you think this is an issue with the coding of the plugin itself? I was hoping this dynamic caching was the solution to my problems with caching!

    Regards,

    Louis

  • Patrick Freitas
    • Staff

    Hi Louis

    Hope you are doing well.

    Sorry to hear this didn’t work, indeed, I can see this part on an example comment:

    ” * The first time dynamic_output_buffer_test() runs it generates the dynamic
    * content and captures it with ob_start() in the DYNAMIC_OB_TEXT constant.”

    Today, I took a calm look on code, and I can see the DYNAMIC_OB_TEXT content is captured on

    ob_start();
    // call the sidebar function, do something dynamic
    echo do_shortcode('[compactgrid_loop_mod orderby="meta_value" show_date="week" show="8" enable_pagination="2" columns="4_col" meta_key="post_hot_count"]');
    $text = ob_get_contents();
    ob_end_clean();

    But only on this part it should define the DYNAMIC_OB_TEXT and assign to that content.

    
    if ( 0 === $cachedata ) { // called directly from the theme so store the output.
    	define( 'DYNAMIC_OB_TEXT', $text );
    } else { // called via the wpsc_cachedata filter. We only get here in cached pages in wp-cache-phase1.php.
         return str_replace( DYNAMIC_OUTPUT_BUFFER_TAG, $text, $cachedata );
    }

    This why moving the line made no difference.

    However, you could run two tests to check if this is the plugin fault, first try to replace your echo do_shortcode() for a normal text, and check if makes any difference.

    Another test is to check the $cachedata, of the first moment it need to return the 0 to call the not cached content.

    You can add this:

    
    var_dump($cachedata);
    exit();
    
    // Normal Code
    if ( 0 === $cachedata ) { // called directly from the theme so store the output.
    		define( 'DYNAMIC_OB_TEXT', $text );
       } else { // called via the wpsc_cachedata filter. We only get here in cached pages in wp-cache-phase1.php.
    	return str_replace( DYNAMIC_OUTPUT_BUFFER_TAG, $text, $cachedata );
    }

    This will show the output using var_dump()
    https://www.php.net/manual/en/function.var-dump.php

    You must see the string(0) on first load page if this is returning anything else might be the cause of the problem.

    Also, try to run those tests on a Vanilla WordPress, only using the plugin that calls the [compactgrid_loop_mod …], cache plugin and the default WordPress theme, it can discard a plugin/theme conflict from the debug list.

    If those tests make no difference, it seems to be a plugin problem.

    Another problem that I found, not related to this error, but on the second code, you have:

    add_cacheaction( 'wpsc_cachedata_safety', 'dynamic_dealgrid_alaune_SINGLE_thumb' );

    The dynamic_dealgrid_alaune_SINGLE_thumb should be

    dynamic_dealgrid_alaune_safety_single_thumb

    To call correctly the function:

    function dynamic_dealgrid_alaune_safety_single_thumb( $safety ) {

    Are you having cache issues when a post is updated?

    Had you tested our Hummingbird plugin?

    https://premium.wpmudev.org/project/wp-hummingbird/

    You can enable the option to clean cache when a Post/Page is updated to avoid some caching problems.

    Best Regards
    Patrick Freitas

  • Louis
    • New Recruit

    Hi Patrick,

    Thank you very much for all your help Patrick, I tried the different steps you forwarded and sadly this seems to be an issue with the plugin, which I can’t ask you to fix haha!!

    I have decided to skip the fragment caching with WP Super Cache and instead load the parts I need through Ajax.

    This caching process is really making me go mad I have to say. I’m not quite sure how to tackle the performance issues I’m sure I will run into once my website starts getting attention…

    I have considered Hummingbird but I don’t think it provides, at least last time I checked, a cache option for logged-in users. WP Super Cache does provide this, meaning that all my nounces and cookies will be correct since a cache file is generated for every user. But in your experience, is creating a cached file for every user going to be a plus or a minus when I start getting quite a few users?

    Thanks once again,

    Regards,

    Louis

  • Rupok
    • Support Ninja

    Hi Louis,

    in your experience, is creating a cached file for every user going to be a plus or a minus when I start getting quite a few users?

    It depends actually. If your site has a few users and there will be a few users in the coming years (e.g. a personal blog site), then you can go for that. But if your site is a member-focused site (e.g. a networking site for a community), then you might need to estimate the number of users you will have and the growth rate and prepare with server resources accordingly.

    Regards,
    Rupok

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.