How do I prevent sitemaps from being cached?

Most cache plugins will, by default, be setup to not cache sitemap files. In the rare case your plugin or server is caching the 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 caching 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 caching this guide may help: How to clear my browser's cache?.

Table of Contents

W3 Total Cache

By default, W3 Total Cache is setup 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)

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

Minify

If you're using W3 Total Cache to minify your pages, please add the following to the "Never minify the following pages:" setting under Performance > Minify > Advanced (section)

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

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:

sitemap(_index)?\.xml(\.gz)?
[a-z0-9_\-]*sitemap[a-z0-9_\-]*\.(xml|xsl|html)(\.gz)?
([a-z0-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 Plugin or Method

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.

Please exclude the following formats:

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

Was this article helpful? ·