[wp-hackers] Feed Caching

Raj list at expost.org
Sat Sep 18 13:59:31 UTC 2010


Yes. That's right. 

-----Original Message-----
From: wp-hackers-bounces at lists.automattic.com
[mailto:wp-hackers-bounces at lists.automattic.com] On Behalf Of iPhoneclub
Sent: Saturday, September 18, 2010 7:12 PM
To: wp-hackers at lists.automattic.com
Subject: Re: [wp-hackers] Feed Caching

Thanks Andrew. So something like this in functions.php should work for
overriding the standard value of 12 hours and providing an even more
aggressive cache lifetime for a specific feed?

/*
Feed Cache - Let's lower the default value to 30 minutes */ add_filter(
'wp_feed_cache_transient_lifetime', create_function('$a', 'return 1800;') );

/*
Even more aggressive caching for specific feeds Hat tip Dougal
(http://dougal.gunters.org/blog/2010/05/20/quick-tip-
faster-wordpress-news)
*/
add_filter( 'wp_feed_cache_transient_lifetime',
'dc_reschedule_rss_fetch', 10, 2 );

function dc_reschedule_rss_fetch( $lifetime, $url ) {
  if ( false !== strpos( $url, 'example.com/feed' ) ) {
    $lifetime = 600; // expire after 10 minutes (600 seconds)
  }
  return $lifetime;
}
_______________________________________________
wp-hackers mailing list
wp-hackers at lists.automattic.com
http://lists.automattic.com/mailman/listinfo/wp-hackers



More information about the wp-hackers mailing list