Home » PHP, wordpress

WordPress RSS Cache issue

12 May 2010 2 Comments

As an administrator for a WordPress MU install, I’ve been getting comments about the RSS feed in WordPress not fetching the latest feeds. The RSS feed information that appears on the page ranges from a fetch that is a few hours to a day old. I’ve confirmed this is an issue with 2.9. This is an issue for blogs that need to pull alerts from an RSS feed within a timely basis, e.g. every 10 minutes.

The workaround to this is to use the KB Advanced RSS feed plugin instead of the one that’s in WordPress. Replace the RSS Widget in Appearance ->Widgets with the “KB Advanced RSS” widget.

If you are using WordPress 2.8+ and want to set the cache to refresh more frequently, go to /wp-content/plugins/kb-advanced-rss-widget/versions/wp-2.8.php

Find this code:
// Regardless, we’ll flush the cache every hour. (WP should flush hourly on its own, though.)
$cachetime = get_option( $this->md5_option_ts );
 if ( $cachetime < ( time() – 3600 ) ){

Change the 3600 to the number of seconds you want the cache to refresh. For instance, 600 for 10 minutes. The plugin uses its own RSS caching system.

I give this plugin 5  out of 5 stars.  It works fine with WordPress 2.9.2 and WordPress 2.9.2 MU (even through the documentation states compatibility  up to 2.8) Formatting options, conversion to UTF-8, reverse listing option, and well commented code.

References:
 http://wordpress.org/extend/plugins/kb-advanced-rss-widget/

2 Comments »

  • WordPress Speed Tricks for Your Site :: WordPress :: WordPress Design & Tutorials said:

    [...] WordPress RSS Cache issue (mostly WordPress MU but still really helpful) AKPC_IDS += "15653,"; Related posts [...]

  • Deryk said:

    this code should also work if you want to improve the cache for certain feeds:

    function scg_filter_feed_duration( $duration, $url ) {
    if ( ‘http://shambhalatimes.org/category/featured-stories/feed/’ == $url )
    return (3600 * 2); // every 2 hours
    else
    return $duration;
    }
    add_filter( ‘wp_feed_cache_transient_lifetime’, ‘scg_filter_feed_duration’, 10, 2 );

    and if you want to improve it for all feeds:

    function scg_filter_feed_duration( $duration ) {
    return (3600 * 2); // every 2 hours
    }
    add_filter( ‘wp_feed_cache_transient_lifetime’, ‘scg_filter_feed_duration’ );

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.