Support » Plugin: WP Super Cache » [Plugin: WP Super Cache] XML Sitemap Feed not cached

  • Hi Donncha,

    My plugin XML Sitemap Feed creates a new feed to present a blogs/sites XML Sitemap dynamically. This seems a viable solution for a WPMU or WP 3.0 Multi Site setup but I have noticed that WP Super Cache does not cache the XML Sitemap even when it does cache normal feeds. At the bottom of one blog (on another server than mine) I noticed

    <!-- Page not cached by WP Super Cache. No closing HTML tag. Check your theme. -->

    While this does not seem to be a problem in case of other rss or atom feeds where the closing tag is </rss> (for instance) the closing tag of the xml sitemap is </urlset>… Any way to make WP Super Cache include the XML Sitemap feed in its cache? Or do I need to change the XML Sitemap Feed plugin in any way?

    Thanks for your thoughts 🙂

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Donncha O Caoimh


    Hmm, that comment should only appear when you have plugin debugging on (in recent versions anyway, are you using an old version?)

    Anyway, the plugin checks if there’s an ending HTML tag AND that the url is not a feed and aborts on failure without caching. The only way I can see around this is by defining a constant to force caching that will sidestep those checks.

    The blog I noticed this remark on is not mine but you can see it here:
    while the regular feed on has the normal “being cached” remarks at the end… I understand the network (WP3.0 in MS mode) has the latest Super Cache installed in mu-plugins.

    Would this mean Super Cache does not recognize it as a feed? How does it check if it’s a feed or not? Maybe I need to do some extra hook-work in XML Sitemap Feed to make it be recogized as one so WP Super Cache includes it in its cache…

    Plugin Author Donncha O Caoimh


    It just uses is_feed() to check. Can you hook into that?

    They must have had debugging enabled then. I just double checked and that warning only shows then.

    Finally figured out why the WP Query would return true for is_feed() at the beginning of the query but not at the end… I have a call for query_posts in the feed template that causes WP to ‘forget’ it is feeding a feed:

    query_posts( array(
    	'posts_per_page' => -1,
    	'post_type' => 'any',
    	'post_status' => 'publish',
    	'caller_get_posts' => '1',

    Simply adding 'feed' => '1' to the array makes the is_feed() condition stay TRUE throughout the whole process.

    Will WP Super Cache be able to work with that?

    Nah! Turns out setting 'feed' => '1' makes WP ignore 'posts_per_page' => -1 so my Loop sticks to the feed limit and probably also 'post_type' => 'any'… Not useful for an XML Sitemap.

    If I place wp_reset_query(); right after the Loop in my feed template, the is_feed() contition is set back to TRUE just before the end.

    Will that work for Super Cache?

    Plugin Author Donncha O Caoimh


    A better solution would be to change $wp_query->is_feed to true which is what is_feed() checks. You won’t upset any other wp_query variables that way.



    Ok, I’d guessed that would amount to the same thing as 'feed' => '1' but you are right, it works fine. Will be in the next release of XM L Sitemap Feed. Thanks, Donncha! 🙂



    But still WP Super Cache seems to ignore the XML Sitemap feed ;(

    I have a WPMU 2.9.2 setup with both WP Super Cache and XML Sitemap Feed 3.7.3 running in /nu-plugins/. Super Cache is in HALF-ON mode.

    I do not see those comforting tags at the end of while they are there on for example…

    Any other cause than the is_feed() condition possible?




    If you have ANY idea, I’d be very grateful.

    I’ve made sure $wp_query->is_feed is set back to TRUE right after the custom query_posts() so throughout the whole template processing, the is_feed() condition returns TRUE except during the query_posts() routine ofcourse.

    I’ve no idea when Super Cache actually catches the condition but caching still does not seem to work with Super Cache 🙁

    Here’s an example of a site with Super Cache debugging enabled:

    Working feed with the nice cache remarks in the source.

    Not working custom feed with the remark <!-- Page not cached by WP Super Cache. No closing HTML tag. Check your theme. --> right at the end.

    Is Super Cache not accepting a closing tag </urlset> at the end of a feed or is the is_feed() condition not returning TRUE at the right moment?

    I’d really love to get caching working with Super Cache too for this plugin since W3TC and Quick Cache do caching of this custom feed without problem…

    Plugin Author Donncha O Caoimh


    Got it. The closing html tag check checks for html/feed/rss tags in the buffer. I added “urlset” and it cached it as a wp-cache file (because of the extra headers).



    Excellent! Much obliged 🙂

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘[Plugin: WP Super Cache] XML Sitemap Feed not cached’ is closed to new replies.