Skip to content Skip to navigation
Back to the main support

How to exclude XML and XSL files from caching plugins

XML sitemaps should never be cached so that Google and other search engines can read their content correctly.

The stylesheet associated in XSL format (equivalent to CSS but for XML), should not be cached either.

Most of the caching plugins automatically exclude these URLs from caching but it’s not always the case.

WP-Rocket

They does the job for you! Nothing to exclude.

We are fully compatible with WP-Rocket and their Preloading sitemap feature:

WP Rocket Sitemap Preloading for SEOPress
WP Rocket Sitemap Preloading for SEOPress

W3 Total Cache

Add these rules to:

  • Performance > Page cache > Never cache the following pages
  • Performance > Minify > Never minify the following pages
  • Performance > Database cache > Never cache the following pages
  • Performance > Browser cache > 404 error exception list
[a-z0-9_\-]*[a-z0-9_\-]*\.(xml|xsl|html)(\.gz)?
([a-z0-9_\-]*?)([a-z0-9_\-]*)?\.xml

Save settings and clear your cache.

Autoptimize

Nothing to exclude. Works out of the box.

WP-Optimize

Nothing to exclude. Works out of the box.

Hummingbird

Add these rules to Hummingbird > Caching page > Exclusions section:

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

Save settings and clear your cache.

WP Super Cache

Add these rules to Settings, WP Super Cache, Advanced:

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

Save strings and clear the cache.

Swift Performance

Go to Tools, Swift Performance, Settings, Caching, General tab. Make sure Cache sitemap option is disabled.

LiteSpeed Cache

Go to LiteSpeed cache, Cache, Excludes tab, and enter this to Do Not Cache URIs field:

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

Conflict with DIVI / Google Fonts loading

We invite you to disableImprove Google Fonts loading” from Divi Theme Options, General tab, Performance sub tab.

Save settings.