Support » Plugin: W3 Total Cache » Fragment Caching on function file

  • I have a one form, and I’m inserting it on page footer from a function file. I need to display a random form to each visitors and thus have a function developed to support this. However, with caching enabled the randomness doesn’t work.

    The site is http://www.nopaccelerate.com/

    So here, I need to exclude certain section of code from caching.

    I tried to put the function inside Fragment Caching which should do the trick, but it gives parse error on the line where I added following code:

    <!--MFUNC {the W3TC_DYNAMIC_SECURITY string}           -->
       //echo rand();
       // I have my custom code here
    
    <!--/mfunc {the W3TC_DYNAMIC_SECURITY string} -->

    Any idea, how to use fragment caching on function file? I am fine with any other idea that works.

    Looking forward to your response.

    Thanks

    http://wordpress.org/extend/plugins/w3-total-cache/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Frederick Townes

    (@fredericktownes)

    What’s the exact parse error?

    Hi Frederick, we got it fixed, it was nothing more than a syntax error. However, I’m still not able to exclude particular block in function file that runs on all our page by inserting it into footer.

    We need to pass a random integer from a given array and based on that it loads random form in the footer.

    Here is a code snippet for you to review:

    <!--MFUNC {E7C5F12EBCDA5F83A41BF33D778ED} -->
       <?php
            //echo rand();
            $surveyforms=array("10","11");
            $ra=$surveyforms[array_rand($surveyforms)];
            echo($ra);
        ?>
    <!--/mfunc {E7C5F12EBCDA5F83A41BF33D778ED} -->

    This should print a random number from an array collection given every time a page is refreshed, however due to cache the result. If we disable caching then it works fine, however as you know caching is very important for performance so we can not disable it.

    I have also tried putting this into footer file directly… but found that this doesn’t work there as well.

    May be a bug?

    Plugin Author Frederick Townes

    (@fredericktownes)

    Remove the {},theyre just an unclear placeholder.

    Hi, thanks for your response.

    This doesn’t work either. Pls advise.

    Thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Fragment Caching on function file’ is closed to new replies.