Support » Plugin: W3 Total Cache » Fragment cache is not working

  • I have followed steps from there but I’m not able to get fragment cache to work (which was main reason to get PRO version)

    Example code inside a template looks like:

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

    so in that case I expect to see The time is and right time but it works only once and then it shows echo ‘The time is ‘.date( ‘H:i:s’, time() ); as a plain text.

    Any clue what is going on?

    Thanks

    https://wordpress.org/plugins/w3-total-cache/

Viewing 2 replies - 1 through 2 (of 2 total)
  • If you view source on the page, what do you see? Just the echo line, or also the mfunc lines?

    Have you tried adding a space between the <!– and mfunc, i.e.

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

    I’ve come across someone else with a similar issue now, and found what the problem was in their case, it could be the same problem for you.

    If you are also using HTML minification, then this will strip out the mfunc comments, and so the PHP code never gets evaluated, but instead just gets output to the page.

    To fix this, on the W3TC Minify settings page, find the section ‘HTML & XML’, then in the ‘Ignored comment stems’ textbox, add ‘mfunc’ (without the quotes). That way the HTML minifcation won’t strip out the mfunc comments, and so the dynamic code should work properly.

    (Note to plugin authors – you may want to consider adding ‘mfunc’ to the ‘Ignored comment stems’ as a default).

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Fragment cache is not working’ is closed to new replies.