How to fix XML sitemap issues caused by WP Super Cache

If you’re not using WP Super Cache and Yoast SEO on your WordPress site you should be. HOWEVER, I’ve finally figured out why I was experiencing XML sitemap issues. It turns out caching messes with sitemaps.

Seems pretty obvious now that I think about it… doh!

The Problem

I was getting all sorts of weird errors on Google Search Console. I’d get URL not found errors, or have files blocked by robots.txt but the URLs were odd strings that shouldn’t have been there in the first place. Google would index images in an odd manner. I’d look at the sitemaps themselves and they weren’t nicely formatted pages like you’d expect. Instead they were lists of URLs running together in a long string.

I use the Yoast SEO plugin to generate my sitemaps. I recommend it for being straightforward yet flexible. Also, it supports things like portfolio post types which I use on this site. This issue also persisted with sitemaps produced by Jetpack and got the exact same thing. I can’t say whether this issue would also persist with other caching plugins, such as W3 Total Cache, but I expect it would.

So, somewhere in the process of WP Super Cache creating the static files it must include the sitemaps in that process. Something about the cached versions of those sitemap files is messed up and causes them to display incorrectly. It must also throw the cat among the pigeons with Google and other web crawlers. Knowing what has caused the error – the fix is pretty straightforward.

The Solution

To resolve this issue, we need to tell WP Super Cache not to cache the sitemap files. Here’s how:

  1. Open your WordPress dashboard, navigate to Settings > WP Super Cache
  2. Click the Advanced tab
  3. Scroll down the page to this section:WP Super Cache settings
  4. Add to this list the file name for each XML sitemap file whatever tool you are using produces. It is common for there to be a sitemap index file that points to other sitemaps that deal with posts, pages, images or other post types separately.
    If your sitemap address is http://www.example.com/sitemap.xml then you only need to put sitemap.xml in this box.
  5. Click Save Strings

When I did this, it resolved the issues where the sitemaps displayed incorrectly immediately. The search engines are likely to need a few days to catch up.

  6 Replies to “How to fix XML sitemap issues caused by WP Super Cache”

  1. June 28, 2017 at 10:58 pm

    I’m looking into this issue now! See #237 for more discussion, but it’ll need support from the plugin authors so their sitemaps can be cached.

    • July 4, 2017 at 7:48 am

      Good to hear!

  2. July 4, 2017 at 3:12 am

    Greg – brilliant! Just had this issue and yours the only post that shows how to fix easily. Thx

  3. August 20, 2017 at 3:16 am

    Very helpful indeed! Have you found any other challenges with the plugin? I just installed and think that i have fixed most issues. Also using Autoptimize.

    • August 20, 2017 at 5:08 am

      Thanks Jerod! No, besides this I’ve had no issues.

Leave a Reply

%d bloggers like this: