3

I'm trying to add a custom feed format to my site (basically exporting data to an Excel file) and I'm getting confused by the feed caching settings. I can't figure out how to flush the cached feeds, or to turn off feed caching altogether while I'm in development.

I've tried deleting all the _transient_feed..., _transient_timeout_feed... and _transient_rss... options, but I'm still seeing the cached feeds.

And, based on some advice in this support forum thread, I tried on a whim adding this line to my wp-config.php:

define('MAGPIE_CACHE_AGE', 0);

(Obviously I'd like some caching of feeds, but it would help in development to be able to turn off the feed caching.)

Anybody got any suggestions?


Some clarification:

Sorry, I think I wasn't clear enough in the initial question, and then I threw you all by referring to the magpie cache, which was completely on the wrong path. I was shooting blind at first.

I'm adding a feed to my site using add_feed(). The function that generates the feed is using the PHPExcel class to write an excel spreadsheet. Then I'm setting appropriate headers for download, and outputting the .xls file data.

I think my problem might actually be a browser caching issue. The urls that I'm trying to output my feeds from look this this: mysite.com/facility/ummc/?feed=master_log and the xls file that's generated is called Master_Log.xls.

Adding a cache busting string to the url request can get around the cache, i.e. requesting a feed from mysite.com/facility/ummc/?feed=master_log&now=12ag4oSduq344 ... I was just wondering if there was any way of disabling the cache altogether.

5
  • How do you add the custom feed?
    – hakre
    Feb 7, 2011 at 23:11
  • is this of any help: wordpress.stackexchange.com/questions/5704/… ?
    – edelwater
    Feb 7, 2011 at 23:34
  • do you have WP_DEBUG on?
    – Bainternet
    Feb 8, 2011 at 1:02
  • 1
    Are you talking about feed you are generating like domain.com/feed/something/ or feed you are retrieving with fetch_feed() ?
    – Rarst
    Feb 8, 2011 at 6:42
  • Clarified. Its a feed that I'm generating. Feb 8, 2011 at 17:36

4 Answers 4

1

It definitely might be a caching issue. I find REDbot is excellent for quick check of how result is served and what are its caching settings.

1
  • Thanks for the link - that was very helpful. Found out - as I was starting to suspect - it wasn't a WordPress issue at all. Tweaking the headers I was outputting with my .xls file solved the problem. Feb 9, 2011 at 18:19
4

If you ever need to just update a single feed RIGHT NOW, for example, to reflect changes made in site settings or a plugin, all you have to do is update any of the posts that appear in the feed.

The reason for this is that WordPress, I conjecture, when serving up a feed, checks all the posts in the feed, and if none of them have been updated since the feed was cached, it serves the cache, but if a post has been updated, it regenerates the feed and refreshes the cache.

This has been useful to me a number of times, for example, when I needed to update a feed for submission to iTunes.

1
  • Decent solution - but I wish there was a way to code something to get around this. Feb 17, 2020 at 20:51
2

try

 function do_not_cache_feeds(&$feed) {
   $feed->enable_cache(false);
 }

 add_action( 'wp_feed_options', 'do_not_cache_feeds' );
3
  • Yep, this would kill caching on fetch_feed() so must note - never use such code in production environment, this can be crazy performance killer and I had encounter crappy plugin in the past that killed caching and pretty much destroyed site's load speed.
    – Rarst
    Feb 8, 2011 at 6:45
  • Didn't do what what I was looking for, but I think my question was just unclear. See my clarification above - I'm not trying to fetch a feed, I'm trying to generate a custom feed. Feb 8, 2011 at 17:45
  • Perfect, this is exactly what I was looking for. I was having problems with my feed not refreshing while I was trying to add custom post types to it...
    – cmcculloh
    Nov 25, 2011 at 17:03
-2

I have been all day find solution to deal with the feed cache as it is not easy to be cleared while I need it as a developer. Finally I got solution by implementing a script that I found here.

I put the script in wordpress root folder so each time I make an update to the source feed I just only do clearing the rss cache by run the script like this:

http://mywordpress.com/reset_wp_rss.php

This script will eliminate the current cached feed so later it will force wordpress to get the new updated feed to show up.

1
  • 3
    What is the code?
    – jnbdz
    Jun 5, 2015 at 23:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.