Another update (2017-12-02): I tried using this method again, and discovered that the second version also no longer works. The following can now be used to stop your feeds from being cached.

function turn_off_feed_caching( $feed ) {
	$feed->enable_cache( false );
}
add_action( 'wp_feed_options', 'turn_off_feed_caching' );

Update (some time around 2015): Rarst just mentioned to me that the Magpie library has been deprecated within WordPress core, and so this is no longer the correct way to flush the RSS cache in WordPress. Instead, you should use the following code.

<?php

/**
 * Setting a new cache time for feeds in WordPress
 */
function prefix_set_feed_cache_time( $seconds ) {
	return 1;
}
add_filter( 'wp_feed_cache_transient_lifetime' , 'prefix_set_feed_cache_time' );

?>

Below is the original post demonstrating the Magpie code.


For the past few days I’ve been driven mildly nuts from dealing with the WordPress feed system. I should have thought of this earlier, but what was causing most of my confusion was that WordPress internally caches the RSS feeds it reads into it. I tracked down the solution whilst rifling through the wp-includes/rss.php file. In there is a definition for the cache age which is set by default to refresh once every hour.

Here is the code from the rss.php file:

<?php

if ( !defined('MAGPIE_CACHE_AGE') ) {
	define('MAGPIE_CACHE_AGE', 60*60); // one hour
}

You can override this via your wp-config.php file by declaring the cache age definition before rss.php has run.

<?php
// Place the following line in your wp-config.php file ... 

define( 'MAGPIE_CACHE_AGE', 10 ); // Cache RSS feeds for only 10 seconds