WordPress.org

Ready to get started?Download WordPress

Forums

WP Super Cache
mfunc is going away in the next version (28 posts)

  1. Donncha O Caoimh
    Member
    Plugin Author

    Posted 1 year ago #

    The next version of WP Super Cache will be released next week. If you use the dynamic cache functionality you'll want to prepare.

    Support for the mfunc/mclude/dynamic-cached-content tags will be removed.

    In their place is a filter called wpsc_cachedata. You can use a WP Super Cache plugin to hook on to that and add or change template tags. It's a lot safer than running exec() on potentially unknown code.

    Download the development version of the plugin on a test server and upgrade your theme if you need to show dynamic content on your site.

    There's more information here, including test code: http://ocaoimh.ie/y/5b

    http://wordpress.org/extend/plugins/wp-super-cache/

  2. nathanfranklinau
    Member
    Posted 12 months ago #

    Hi,

    Just wondering how this method is supposed to work when you want to replace your template tag with a function like get_sidebar() which requires the use of ob_start() to get the output so it can be replaced in the output string.

    Am I missing something?

    Thanks!

  3. Donncha O Caoimh
    Member
    Plugin Author

    Posted 12 months ago #

    Output buffers can be nested so as long as you get the contents of the buffer and clean/close it properly there shouldn't be an issue.

  4. nathanfranklinau
    Member
    Posted 12 months ago #

    I tried the following code:

    add_cacheaction("wpsc_cachedata", "ch_replace_dynamic_content");
    function ch_replace_dynamic_content($cachedata) {
        ob_start();
        print "test";
        $cachedata .= ob_get_clean();
    
        return $cachedata;
    }

    But I get the following error:

    Fatal error: ob_start(): Cannot use output buffering in output buffering display handlers in xxxxxx.php

    Any tips?

  5. Donncha O Caoimh
    Member
    Plugin Author

    Posted 12 months ago #

    Do you have compression enabled in your php.ini?

    I searched for that error message and the first result says to turn compressed output buffers off.

  6. nathanfranklinau
    Member
    Posted 12 months ago #

    Not that I can see. I checked my php.ini and also my runtime phpinfo(); Doesn't look like it. Anything else you could recommend?

  7. nathanfranklinau
    Member
    Posted 12 months ago #

    Just to confirm does the code I posted work for you?

  8. Donncha O Caoimh
    Member
    Plugin Author

    Posted 12 months ago #

    Unfortunately I don't have time to test it and I don't use this functionality on any of my sites. If I have time to, I'll test it out later.
    Unfortunately I don't know why you're seeing that error message. :(

  9. Young Master
    Member
    Posted 12 months ago #

    What is dynamic cache functionality? Am using mod_rewrite. Is that dynamic cache? Can anyone explain this to me?

  10. nathanfranklinau
    Member
    Posted 12 months ago #

    Dynamic caching means to have components on your page that are not cached with the plugin. This bits will always be executed when a user loads the page. This is useful for displaying content that needs to change on every page load.

  11. nathanfranklinau
    Member
    Posted 12 months ago #

    Hi Donncha,

    I'm pretty sure you can't use output buffering functions inside an output buffering handler function.

    See: http://php.net/manual/en/function.ob-start.php in the section output_callback.

    Does this mean as of version 1.4 we won't be able to use dynamic content in page caching?

    Nathan

  12. Young Master
    Member
    Posted 12 months ago #

    Will this new version of WP Super Cache resolve the issue of corrupted cache which makes WP Super Cache display Blank Pages on the home page and other important pages?

  13. Young Master
    Member
    Posted 12 months ago #

    Will this new version of WP Super Cache resolve the issue of corrupted cache which makes WP Super Cache display Blank Pages on the home page and other important pages?

  14. Donncha O Caoimh
    Member
    Plugin Author

    Posted 11 months ago #

    @nathanfranklinau - As it currently stands you won't be able to use an output buffer because of that restriction.

    There are 2 ways around it - the plugin could use a shutdown function to push the page to the browser which would happen after the ob callback so you could use a new output buffer. I tried implementing this but it's troublesome because of the way processing the output buffer is done. I'm not sure if I'll get this into the plugin before the next release.

    Or you use Javascript to insert the right content where it should go. If I wanted to create dynamic sections of my page I'd use this and not sacrifice caching speed at all.

  15. Donncha O Caoimh
    Member
    Plugin Author

    Posted 11 months ago #

    @Young Master - I don't know. This might be an issue with your hosting or a bug in the plugin or a conflict with another plugin. That report is too vague, you'll have to try to debug it I'm afraid.

  16. nathanfranklinau
    Member
    Posted 11 months ago #

    Hi Donncha,

    For now, I have rolled back to 1.3.2 and I have added a cache secret key to the code like W3 Total Cache does it.

    Have you made any other changes to 1.4 like bug fixes or anything else like that?

    Nathan

  17. gooma2
    Member
    Posted 11 months ago #

    @Donncha O Caoimh

    The blank page syndrome is also occurring to users of W3TC which started shortly after the last WP update.

    """@Young Master - I don't know. This might be an issue with your hosting or a bug in the plugin or a conflict with another plugin. That report is too vague, you'll have to try to debug it I'm afraid."""

    I was about to uninstall that one and reinstall WP Supercache until I saw that others are having the blank white page issue too.

    Our hosting provider (Liquid Web) said that they've had thousands of clients contacting them about the problem and it's a caching issue.

  18. Young Master
    Member
    Posted 11 months ago #

    @Donncha O Caoimh, I dont think if this issue is caused by conflict with another plugin or an issue with my web host because I have got several websites each running on different web host and all of them are experiencing the same problem.

    If you look around the Internet you will see that this issue has been occurring for a while – years. What is frustrating is that WPSC is totally awesome except for this one issue.

    I tried to find a solution of this problem with Bullet Proof Security Plugin Author who is also experiencing the same problem but we couldnt find a solution for this problem.

  19. poffy
    Member
    Posted 11 months ago #

    @Donncha O Caoimh

    Can you help me explain what may cause this error ?? :)

    http://content.screencast.com/users/Kim1243/folders/Jing/media/3f3bc797-754e-4e1f-9785-5446d2993e18/2013-08-02_0147.png

    Thanks

  20. davemee
    Member
    Posted 11 months ago #

    @Young\ Master and @gooma2 - your problem may be related to a duff distribution of php-apc. I know WPSupercache will try to use it, if installed, and W3TC has options to hook it in.

    Try removing it (assuming you have it). I saw tell-tale errors in my logs about failed cache access. It absolutely killed a box of mine.

  21. Young Master
    Member
    Posted 11 months ago #

    Thank you @davemee for your advice but unfortunately I dont use APC in any of my web hosting accounts.

  22. Donncha O Caoimh
    Member
    Plugin Author

    Posted 10 months ago #

    @nathanfranklinau - try the development version of WP Super Cache. I added really experimental code that uses the shutdown hook to display the buffer if dynamic caching is enabled. You should be able to use an output buffer in the wpsc_cachedata cacheaction hook now.

    It does come with a warning. The request that generates the cached page won't serve a compressed page. I could not, for all my trying, get that to work properly. Unless that gets fixed I'll probably revert the change as it adds to the complexity of the plugin for a feature that is unfortunately only used by a minority of sites. Any patches or help is welcome!

    http://ocaoimh.ie/y/2o

  23. JW555
    Member
    Posted 9 months ago #

    If you have a new version coming out can you please fix th emajor fail of WP Super cache using absolute addresses rather than relative that makes it fail a server migration

  24. Donncha O Caoimh
    Member
    Plugin Author

    Posted 9 months ago #

    JW555 - unfortunately not. I've tried that in the past but some hosts have really weird setups where the filesystem path seen by Apache is not the same seen by PHP.

    I do need to make the recovery from that error better. There's no reason the plugin couldn't fix the path itself. It all takes time however of which I am short of these days.

  25. Donncha O Caoimh
    Member
    Plugin Author

    Posted 8 months ago #

    I reverted the buggy code that would let you use an output buffer callback. It was overly complicated and depends on PHP's shutdown process which I don't 100% trust. After reviewing the code this evening something is sending output to the browser and then the gzip headers were ignored. The code was there to be tested for a month but nobody commented on it or helped fix the bugs.

    Unfortunately this means site owners won't be able to use an output buffer when generating the dynamic bits in dynamic pages but at least the plugin will finally be rid of any mention of eval().

  26. Donncha O Caoimh
    Member
    Plugin Author

    Posted 8 months ago #

    I realised this morning that there's an easy work around. If you must use a dynamic cache call your dynamic code in the theme or as an action hook wherever it's supposed to be. This will make sure that the first cached page has the dynamic bit.

    But also hook it onto the cacheaction for the cached pages. To stop it executing twice when the cached page is generated set a flag and check for that. I'll update the example plugin over the next few days.

  27. Donncha O Caoimh
    Member
    Plugin Author

    Posted 8 months ago #

    I checked in code yesterday to support using an output buffer. Here's my post about it. Barring any last minute bugs there'll be a release tomorrow.

    http://ocaoimh.ie/y/6j

  28. Donncha O Caoimh
    Member
    Plugin Author

    Posted 8 months ago #

    And version 1.4 is out. More details here: http://ocaoimh.ie/y/6l

    If you're using mfunc et al do not upgrade. Read that post first as you'll need to update your sites.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic