• Hello! I’m trying to configure Fragment Caching, but it don’t working. I see this message: “Unable to execute code: The time is 13:27:38 <br>;”

    I’m following this tutorial: https://www.justinsilver.com/technology/wordpress/w3-total-cache-fragment-caching-wordpress/

    So, I’m using Page cache method Disk: Basic with Late initialization enabled. All other caches are disabled. Also, I added this

    define( 'W3TC_DYNAMIC_SECURITY', md5( rand( 0, 999999 ) ) ); // random "secret"
    

    to my wp-config.php file.

    And here is my code, that I try exclude from cache (it is placed inside single.php file):

    <!--mfunc <?php echo W3TC_DYNAMIC_SECURITY; ?> -->
    <?php
    echo 'The time is: '.date( 'H:i:s', time() )." <br>";
    ?>
    <!--/mfunc <?php echo W3TC_DYNAMIC_SECURITY; ?> -->

    Also I noticed, that this message: “Unable to execute code:” appears only on first page load. After that, page loads with same cached time: “The time is 13:27:38”

    Any help will be appreciated.

    • This topic was modified 6 years, 2 months ago by dmykos.
Viewing 2 replies - 1 through 2 (of 2 total)
  • You shouldn’t have the <?php and ?> parts around the echo call.

    Thread Starter dmykos

    (@dmykos)

    Thank you for response.
    Now I’m using this code:

        <!--mfunc <?php echo W3TC_DYNAMIC_SECURITY; ?> -->
    echo 'The time is '.date( 'H:i:s', time() );
        <!--/mfunc <?php echo W3TC_DYNAMIC_SECURITY; ?> -->

    And it outputs this on first page load

    The time is 17:29:25

    And this on all next page loads:

    echo ‘The time is ‘.date( ‘H:i:s’, time() );

    So, it works only on first page load.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Fragment Caching don’t work: “Unable to execute code: “’ is closed to new replies.