WordPress.org

Ready to get started?Download WordPress

Forums

WP Super Cache
Dynamic Cache not working (16 posts)

  1. hawaiifi
    Member
    Posted 3 years ago #

    Wp Super Cache works great until I add the following to my head.php file:

    <!--dynamic-cached-content--><?php
    youAreHere($post->ID);
    ?><!--
    youAreHere($post->ID);
    --><!--/dynamic-cached-content-->

    Now when I test the cache I get the following message:

    The pages do not match! Timestamps differ or were not found!

    And the pages on my site are blank.

    The function I am trying to call is in my functions.php file. The following works with WP Super Cache turned off:

    function youAreHere($postid){ //This creates the breadcrumb
    if(function_exists('zg_recently_viewed') && isset($_COOKIE["WP-LastViewedPosts"])){
    $crumb = zg_recently_viewed($postid);
    }else if(function_exists('bcn_display')){
    $crumb = '<p class="breadcrumb">You Are Here:  '.bcn_display().'</p>';
    }
    return $crumb;
    }

    I'm using PHP to cache.

    Is there a better javascript solution to call the php using $post->ID where I can use mod_rewrite?

    Mahalo for the help.

  2. Donncha O Caoimh
    Member
    Plugin Author

    Posted 3 years ago #

    Enable "Late init" on the advanced settings page. There's a FAQ about it in the documentation.

  3. anchel
    Member
    Posted 3 years ago #

    Same here ... I Get
    <!-- File not cached! Super Cache Couldn't write to: " full path ... " -->
    In debug I see that the files couldn't write to /wp-content/cache/supercache
    After delete of this folder it isn't rebuilding again .. Or after making this folder right with permissions it's also giving the error .
    Switching php or mod_rewrite makes no difference .. or Late init ...

    Cheers,
    Michel
    http://skilfan.anchel.nl

  4. Donncha O Caoimh
    Member
    Plugin Author

    Posted 3 years ago #

    anchel - your problem is different to the previous one. Unfortunately I can't help as there's a permission problem on your server.

  5. anchel
    Member
    Posted 3 years ago #

    ok you say so ... Have it on 4 blogs ...

  6. Donncha O Caoimh
    Member
    Plugin Author

    Posted 3 years ago #

    Are the 4 blogs on the same host or server? You need to check the folders on your server, and check the modules loaded by your webserver. Maybe there's some security module that will only allow PHP to write to files owned by the same owner. There are lots of reasons why you're getting this problem unfortunately.

  7. anchel
    Member
    Posted 3 years ago #

    Yes same host .. but it's after upgrading to 0.9.9.9 and if I delete cache folder in the wp-content .. the plugin creates a new folder cache with meta in it but no supercache folder ...
    Thats strange ..

  8. anchel
    Member
    Posted 3 years ago #

    Reinstalled 0.9.9.8 and it's back up and running ...
    supercache folder is created and works fine ..

    sorry to say .. something in 0.9.9.9 is broken ..

  9. Donncha O Caoimh
    Member
    Plugin Author

    Posted 3 years ago #

    Odd, that works fine for me and everyone who was testing the dev version. Grr.

    If you can, install the latest version on one of your blogs and try to debug around line 405. That's the only chunk of code that changed between the two versions that might cause a problem for you. Thanks.

  10. hawaiifi
    Member
    Posted 3 years ago #

    Thanks for the help donncha. I tried what you said:

    1. Set $wp_super_cache_late_init to "1" in wp-content/wp-cache-config.php
    2. Enable "Late init" on the advanced settings page.

    And now I get this error when I test my home page:

    Parse error: syntax error, unexpected T_STRING in /home/gom/public_html/wp-content/plugins/wp-super-cache/wp-cache-phase1.php(204) : eval()'d code on line 96

  11. hawaiifi
    Member
    Posted 3 years ago #

    I also tried in Legacy mode and get the same error.

    If I use this bit of code instead:

    <!--mfunc youAreHere($post->ID); -->
    <?php youAreHere($post->ID); ?>
    <!--/mfunc-->

    The error goes away, but the pages are still blank.

  12. Donncha O Caoimh
    Member
    Plugin Author

    Posted 3 years ago #

    hawaiifi - look at the cached file and you might see the syntax error generated. You might need to use the debug file to find out what cache file to look for.

    Also, $post doesn't exist when cached as the loop doesn't run. :( You'll have to cache that somehow when the page is generated.

  13. hawaiifi
    Member
    Posted 3 years ago #

    $post->ID appears to be the culprit creating the error. I was able to solve this by echoing the commented lined using PHP like so:

    <?php echo '<!--mfunc youAreHere('.$post->ID.'); -->'; ?>

    But when a page is cached, my function is still not working. Do I need to make sure funtions.php is not cached? How would I do that?

    Should I just be using AJAX to call this function? It seems like that would allow me to turn off "Late init" and get things loading even faster.

  14. Donncha O Caoimh
    Member
    Plugin Author

    Posted 3 years ago #

    Yeah, ajax is better for this sort of thing!

    anchel - thanks for letting me into your server to investigate. The problem was that you had capital letters in your filesystem path and a unicode fix in .9 was to lowercase everything. I fixed this by lowercasing only the URI.

    To fix this on your other blogs grab wp-cache-phase1.php and copy it into wp-content/plugins/wp-super-cache/, overwriting the file of the same name there.

  15. anchel
    Member
    Posted 3 years ago #

    Thanks for the fix! Great Job.

    Cheers from Holland.

  16. Inposure
    Member
    Posted 3 years ago #

    Speaking of Capital letters, it seems that super cache doesn't care about capital letters in escape sequences. I have the following URI on my site:

    /om-%25e4%25b9%258b%25e4%25b9%258e%25e8%2580%2585%25e4%25b9%259f

    But sometimes, through stupid "normalization" by bots and clients, this becomes:

    /om-%25E4%25B9%258B%25E4%25B9%258E%25E8%2580%2585%25E4%25B9%259F

    This is cached as a separate instance by super cache.

    Not a big deal, but something that can't easily be changed on the htaccess level.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic