• Resolved idnr1

    (@rm04)


    I’m trying to implement Fragment caching to achieve the following.
    cache all pages/links unless stated otherwise.
    don’t cache the shopping basket (since it is on every page)

    I can cache pages and preload them.
    i have certain woocommerce categories i don’t want to be cached.
    As of now it’s not clear to me if i’m using the right codes and if that works as wanted.

    Fragment cache doesn’t seem todo or works differently or lacks documentation since all i could find online was the below.

    inside wp-config.php i added the following.
    define('W3TC_DYNAMIC_SECURITY', 'Donnotcachethis');

    Inside my header.php i placed the below code for testing purposes.

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

    This shows the current time on first page request, but same time keeps getting displayed on every f5 i use.

    Both Page cache and Fragment Cache use redis server.
    Late initialisation is active

    And for the rest there is no information anywhere about this topic!

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @rm04

    I am sorry about the issue you are experiencing and I am happy to assist you with this.
    People often think that Page Fragment Cache and Fragment Cache are the same things but this is not the case . Fragment Cache module which was developed in W3 Total Cache for capturing the output of do_action() calls, or when theme uses our functions to store/get some values.
    Page Fragment Caching, however, is used to wrap a PHP code with <!–mfunc –> comment.
    You can check more about Page Fragment cache in our FAQ page and in this article.

    Example for date and time:
    in wp-config.php add the following.
    define(‘W3TC_DYNAMIC_SECURITY’, ‘Donnotcachethis’);

    Set the Page Cache method to disk(or better yet a memory based method), enable late initialization. In performance>minify, and scroll down to HTML & XML sub-box. There you need to add mfunc and mclude in “Ignored comment stems:” textbox.
    Now you can Replace PHP tags with comments :
    So in your template add the following:

    <!-- mfunc Donnotcachethis -->
    echo date('Y-m-d H:i:sa');
    <!-- /mfunc Donnotcachethis -->

    Save the changes in the template and save all settings and purge the cache in W3 Total Cache.
    As you can see you need to replace W3TC_DYNAMIC_SECURITY’ with ‘Donnotcachethis’ in mfunc as that is what you defined.
    I hope this helps!

    Thread Starter idnr1

    (@rm04)

    So if i understand you correctly minify needs to be activated and then add mfunc and mclude in “Ignored comment stems:” textbox.

    Since i had minify turned off, that will never work?

    Ill try it tonight and will get back to u if it failed.

    Thanks so far for the quick response

    –edit–

    I just checked your document and it states the below

    The last thing that needs to be done depends on whether the Minify setting is enabled or not. If Minify setting is indeed enabled, we need to goto Performance> Minify and scroll down to HTML & XML sub-box. There we need to add mfunc and mclude in “Ignored comment stems:” textbox.This concludes the part where we play with the W3 Total Cache settings and now we go to a more interesting part.

    I only have page caching and Fragment cache activated.

    I’m also gonna try with minify enabled, ill keep this post updated.

    • This reply was modified 6 years, 1 month ago by idnr1. Reason: adding extra information
    Thread Starter idnr1

    (@rm04)

    Also when turning on Minify, the time doesn’t get updated.

    Could it perhaps be that page cache overrulles the mfunc command?

    Thread Starter idnr1

    (@rm04)

    i tried without php tags

    echo date(‘Y-m-d H:i:sa’);

    On page load it shows the time but as soon as u refresh by using F5 it returns

    echo date(‘Y-m-d H:i:sa’);

    so it looks like the cached version isn’t refreshing that data

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @rm04

    In the previous topic, you have all the information needed.
    This is all tested and I have the same code on one of my websites and it’s working like a charm.
    So once again:
    define('W3TC_DYNAMIC_SECURITY', 'Donnotcachethis'); in wp-config.php
    Page Cache caching method needs to be on Disk (so not disk: Enhanced)
    Enable Late initialization.
    Now you can wrap the “echo” with mfunc:

    <!-- mfunc Donnotcachethis -->
    echo date('Y-m-d H:i:sa');
    <!-- /mfunc Donnotcachethis -->

    In this screenshot, you sen see my footer and the code in it.
    Please note that I’ve added define( 'W3TC_DYNAMIC_SECURITY', 'datetime' ); to my wp-config.php but since you’ve added define('W3TC_DYNAMIC_SECURITY', 'Donnotcachethis');
    you should use the code provided above.
    Thank you!

    Thread Starter idnr1

    (@rm04)

    Ok the only thing i had differently was that i was using Redis instead of Disc.

    And these are the results i’m getting,

    When i use the code below in my header.php

    <!-- mfunc Donotcachethis -->
    echo date('Y-m-d H:i:sa');
    <!-- /mfunc Donotcachethis -->
    <?php echo date('Y-m-d H:i:sa'); ?>

    and in wp-config.php

    
    define('W3TC_DYNAMIC_SECURITY', 'Donotcachethis');

    then i flush all cache and open a page and it shows me the below results.

    2020-04-07 11:43:35am 2020-04-07 11:43:30am

    So both codes are executed, then when i press F5 the expected behavior should be that the first “time” get’s updated as it is dynamic content and the second time should stay the same as it should be cached. now the results i get back after pressing F5 to refresh the browser.

    echo date(‘Y-m-d H:i:sa’); 2020-04-07 11:43:30am

    Let me also mention that i tried the behavior with caching on and off for the setting below. The above result is to also cache pages with logged in users.

    Don’t cache pages for logged in users

    When i turn cache off for Logged in users both times get updated all the time so nothing is cached.

    I’m kinda shooting in the dark now since i used the settings as proposed but i’m not getting what i want as shown above.

    Hopefully u might have an idea on how i can troubleshoot this any further and if it’s even possible to achieve what i’m trying todo.

    Thanks for the help so far tho.

    • This reply was modified 6 years, 1 month ago by idnr1. Reason: added info about wp-config
    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @rm04

    At this point, I can offer you our professional support so you can drop us a note via the plugin in Performance>Support.
    This is tested numerous times and it’s working. You have the documentation provided.
    Thank you!

    Thread Starter idnr1

    (@rm04)

    Hello Marko,

    My issue isn’t resolved so it’s a bit weird u put it on resolved.

    This is how i stand in this;

    I tried your free plugin, which is ok.
    I found out i need to exclude some things in the header.php and your program litterly told me i could do that if i bought the upgrade to pro. so i did.

    The settings u said i need to get the solution i want don’t work for me….
    So now your telling me i bought a pro version and get zero support concerning my issue.

    So what did u guys achieve by working like this is;
    1. I bought somthing i don’t need, so ill try to refund it and dispute it with the credit card company.
    2. U will get a BAD review
    3. Even if i can’t get a refund, since i see more bad messages about your company with situations like this, i will sure not extend the license…..

    At the end, u guys could have had a very simple satisfied customer that would have paid a renewal every year….

    It’s a very bad thing to let customers who paid for extra functionality that does not work out of the box offer extra paid services……

    Hereby i would not suggest anyone who needs more then an out of the box configuration to use your plugin unless they are prepared to pay u guys for the configuration.

    So as of now i’m gonna tell my client to stop with u guys….

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @rm04

    The feature you are referring to is Page Fragment Cache. This is available for free users. Fragment Cache is a Pro Feature available after the upgrade.
    Since you are a Pro user (you did not mention that), and the WP rules forbid the support for the premium users in the Forum, We cannot provide support here.
    Please contact us via the plugin as mentioned or so we can assist you with this.
    Once again as the forum rules suggest and the sticky post in this forum:

    1.Support is provided in the for non-premium (free) users only, issues related to your premium subscription or account should not be posted in the forum.

    https://ww.wp.xz.cn/support/topic/read-before-posting-93/

    Thank you!

    Thread Starter idnr1

    (@rm04)

    I always said Fragment cache, and sorry for the fact i posted my problem here and not from inside the plugin, inside the plugin it looks like u only want to sell more configuration hours which i don’t want….

    I created a workarround now with ajax to update the elements in cached versions which somehow works. I would have preferred a solution within W3 total cache but since i as a user walked this way and get to this solution says a lot about your support options…… (u might wanna think about that, since i probably won’t be the only 1)

    I will reply to the license email and will only put a link to this post in it so u guys can contact me if u wanna solve it or not. for me i’m at a point now that i don’t rlly care anymore if u guys wanna solve it or not.
    So if u guys wanna solve it u can contact me by replying to that email.

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @rm04

    Thank you and We received the email. As for the support options, “Submit a bug report” is an option for any issue that might occur and it’s completely free.
    We’ll continue the correspondence via email.
    Thank you!

    Thread Starter idnr1

    (@rm04)

    I receved your email and just replied, sorry for my frustrated reaction i guess.

Viewing 12 replies - 1 through 12 (of 12 total)

The topic ‘Fragment Cache not working’ is closed to new replies.