WordPress.org

Ready to get started?Download WordPress

Forums

WP Super Cache
Prevent caching of PHP date (5 posts)

  1. Jamil Jonna
    Member
    Posted 2 years ago #

    Hi,

    First, thank you for the excellent plugin. I'm trying to prevent the date from caching on the main page of my site, monthlyreview.org. I insert the date using a filter in functions.php. It is a simple php date, i.e., date('l F jS, Y'). Problem is that it gets cached with the main page and doesn't change. from day to day, even though I have garbage collection set to 1 hour.

    Is there any way to prevent the date from getting cached?

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

  2. Jamil Jonna
    Member
    Posted 2 years ago #

    So actually slogged through the documentation (which needs updating) and have been trying to use the mfunc but to no avail. Here is the function I created in my plugin (just a set of custom actions for my site):

    function mr_time() {
    
    		$d = "date( 'l F jS, Y, g:i a (T)' )";
    		$cd = '<!--mfunc ' . $d . ' -->';
    		$datec = date( 'l F jS, Y, g:i a (T)' ) . '<!--/mfunc-->';
    		$date = '<div class="todays-date">' . $cd . $datec . '</div>';
    
    		echo $date;
    }

    The uncached page works correctly. Cached versions show nothing. I've tried the quotation marks in all sorts of configurations since the date in mfunc renders otherwise.

    Any help is much appreciated.

  3. Donncha O Caoimh
    Member
    Plugin Author

    Posted 2 years ago #

    and how are you calling the mr_time() function in your template?

  4. Jamil Jonna
    Member
    Posted 2 years ago #

    as an action.

    add_action( "{$prefix}_open_main", 'mr_time' );

    i'm using the hybrid theme framework. Oh, and I forgot to mention that I do have "Late init. Display cached files after WordPress has loaded. Most useful in legacy mode." checked in Advanced.

  5. Donncha O Caoimh
    Member
    Plugin Author

    Posted 2 years ago #

    Look in a cached page in wp-content/cache/ and see if the date command is in there. Also use the debug system to see if it uses legacy mode..

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic