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

yoastseo
wordpressplugins
wpsupercache

(Amit Malewar) #1

Content-type returned by sitemap URL is content-type:text/html; charset="UTF-8" which is wrong.

The problem is that Yoast’s plugin needs to tell Supercache that the URL is a sitemap.

As a temporary fix, you can add the following to the Add here strings (not a filename) that forces 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)?

(Ratnesh Sonar) #2

Hi Amit

Thanks for your quick fix,
I got it whatever you’ve explained, but please elaborate in more details for other forum members.
as few of our forum members are quite new to WordPress.

Regards,
Ratnesh


(Amit Malewar) #3

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.