How do I prevent sitemaps from being cached?

Most cache plugins will, by default, be configured not to cache sitemap files. In the rare case your plugin or server is caching any sitemap,  please add an exclusion for the sitemap files to your cache plugin. The steps vary by cache plugin, so please select your cache plugin below.

When finished, be sure to clear your cache from your plugin, theme, server, browser, or CDN such as Cloudflare. If you are not sure how to clear your server caching, please speak with your host provider. If you need to clear your browser cache, this guide on how to clear your browser’s cache may help.

Table of contents

W3 Total Cache

By default, W3 Total Cache is set up to not cache the Yoast sitemaps. Enabling some W3 Total Cache features may cause the sitemaps to be cached.

404 errors for static objects

If you’re using the setting ‘Do not process 404 errors for static objects with WordPress’, please add the following to the ‘404 error exception list’ under Performance > Browser Cache > General (section).

Minify

W3TC caching plugin minify exclusions

WP Super Cache

Go to Settings  > WP Super Cache and click on the Advanced tab.  Scroll down to the section where it says “Add here strings (not a filename) that forces a page not to be cached” and add the following:

index\.php
sitemap(_index)?\.xml(\.gz)?
[a-z0-9_\-]*sitemap[a-z0-9_\-]*\xml|xsl|html)(\.gz)?
([az0-9_\-]*?)sitemap([a-z0-9_\-]*)?.xml

WP Rocket

WP Rocket offers sitemap preloading. Learn more here.

To prevent WP Rocket from caching the sitemaps, go to Settings > WP Rocket > Advanced Rules > Never Cache URL(s) and exclude the following:

/(.*)sitemap(.*).xml
/(.*)sitemap.xsl

Other cache plugins or methods

If you are using a different plugin or caching is done at the server level then contact the plugin developer or your hosting company for support.

Get free SEO tips!