[Quick Fix] Yoast SEO compatibility issue with WP Super Cache

Posted in: Newspaper
Post count: 623

It’s a side-effect of how the sitemap is generated by Yoast SEO (and I presume other sitemap plugins). They exit as soon as they send the sitemap to the browser which stops WordPress actions and filters from running. They don’t always set the current URL as a feed either.

For reasons long forgotten, but probably related to working around plugins that change the is_feed() settings WP-Super-Cache caches the status of the current page. It then uses that information to see if it should skip caching the page. That caching is fired on the “template_redirect” action, but since the sitemap plugin has exited that action won’t fire. Then later, the plugin checks if is_feed() is true (it should use the cached information, that’s an oversight) but since the sitemap plugin doesn’t set that either, it’s not.

As a result of is_feed() returning false, the plugin caches the sitemap as an anonymous html page which uses the text/html content type, not text/xml.

As a temporary fix, you can add the following to the Add here strings (not a filename) that force a page not to be cached in ADVANCED setting section.

sitemap(_index)?\.xml(\.gz)?
([a-z0-9_\-]+)?sitemap\.xsl
[a-z0-9_\-]+-sitemap([0-9]+)?\.xml(\.gz)?

Viewing 1 post (of 1 total)
You must be logged in to reply to this topic.