A couple of days ago I wrote about how to use a RSS feed with the WordPress fetch feed function.
I was excited about figuring this out because I could place the feed wherever I wanted and didn’t have to worry about using a plugin.
I set it up in the evening and bookmarked a new page that should have updated the feed the following morning. Later in the day I noticed the feed hadn’t updated with the new bookmark so I started to worry that I hadn’t set it up properly or that it wasn’t going to be a workable solution.
So, I started to search and ask how often the fetch feed function pulls in the new feeds. I could not, however, find an answer to my question. That’s because I was asking the wrong question. The WordPress feed cache is what determines how often the feed is pulled in. In my search for answers I finally found this article by WP Engineer – Feed Cache in WordPress.
The article explains that by default the feed cache checks for updates to the feed every 12 hours. This is why me feed hadn’t updated. I had added the code almost 24 hours earlier but it hadn’t been 12 hours since I added the most recent bookmark to be pulled in.
The article also lists different ways to increase how often the field is pulled. I used the following code and added it to my functions file, functions.php:
<?php add_filter( 'wp_feed_cache_transient_lifetime', create_function( '$a', 'return 1800;' ) ); ?>
wp_feed_cache_transient_lifetime is a hook that works with the fetch feed function and can set how often the feed is checked for updates. The number 1800 refers to seconds, so in this example it is checking every 30 minutes. It probably doesn’t need to be this often – maybe something between 30 minutes and 12 hours ;-)
As WP Engineer mentions, this hook can be used in a function or in a plugin and can also be used with conditionals so that the feed is only checked and updated when specific pages are loaded.
So, mystery solved as to why my feed wasn’t being updated and I learned a little but more about WordPress that I intended when I first started playing with the fetch feed function.
photo credit: ~Sage~
Julie @ Life Domestic says
What would make your feed suddenly stop working? It has been a month now that my feed no longer works. I had changed nothing just had a reader email me that my feed didn’t work, I have tried to figure out why to no avail. It aggravated me so much I finally gave up. (plus have been super busy over the last month trying to find a new place to live I have barely even posted) but I don’t want to loose the people that are subscribed.
Feeds seem to be the thing I have the most trouble with. It took me forever to get it to work the first time. I had tried using feedburner and it worked for awhile and quit so I got rid of it and things were going great for several months then poof! gone again.
Kim Woodbridge says
Hi Julie – Did anything else change around the same time? For example, was WordPress upgraded or was a new plugin installed? Are you using the Feedburner plugin to redirect the feed?
Also, the link for the RSS subscribe image is incorrect – it says
http://lifedomestic.com/www.lifedomestic.com/feed/rss – that needs to be fixed.
When I try variations such as lifedomestic.com/feed a blank RSS page comes up – this leads me to believe that it’s a plugin causing the problem. You could try deactivating all plugins and then testing.
Unfortunately, this article is unrelated to this issue – this article is about adding a feed to your page templates like the WordPress bookmarks one I have in the footer.
Dennis Edell says
I may come to you when I get to that project i hinted to on the last post. ;)
.-= Dennis Edell´s last blog ..Blog Move Is Imminent ! I’m Looking For Launch Partners… =-.
Matthew says
Hi Kim,
I found your article after Googling: “Increase cache speed of wordpress feed” or may be a similar one (I don’t exactly remember).
I, too, was looking to make the WP feed cache pull the feed more often. So, should I enter the code to functions.php? Is there a plug in that does this job for us?
Kim Woodbridge says
Hi Matthew – The code goes into the functions.php file. I am not aware of a plugin that does the same thing.
Dheeraj SIngh says
All feeds are cached in the wp_options table when the fetch_feed function is used, is there a way to cache it in a file like simplepie does.