Title: Does SGO Cache Sitemaps?
Last modified: October 11, 2022

---

# Does SGO Cache Sitemaps?

 *  Resolved [generosus](https://wordpress.org/support/users/generosus/)
 * (@generosus)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/does-sgo-cache-sitemaps/)
 * **Good Day,**
 * Does SGO cache sitemaps? If so, we have a couple of questions:
 * (1) Is there a SG filter or code snippet we can use to bypass sitemaps?
 * (2) Does the SGO setting feature, “Exclude URLs from Caching”, accept URLs in
   regex format? For example: `sitemap?\.xml?` — or — `/(.*)sitemap(.*).xml`
 * Thank you!
 * ———————–
 * **Note:**
 * Unfortunately, the following topics did not answer our questions:
 * [https://wordpress.org/support/topic/exclude-sitemap-from-caching/](https://wordpress.org/support/topic/exclude-sitemap-from-caching/)
   
   [https://wordpress.org/support/topic/i-am-having-issue-with-no-caching-sitemap-pages/](https://wordpress.org/support/topic/i-am-having-issue-with-no-caching-sitemap-pages/)
   [https://rankmath.com/kb/exclude-sitemaps-from-caching/](https://rankmath.com/kb/exclude-sitemaps-from-caching/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Support [Tsvetan Mitev](https://wordpress.org/support/users/tsvetanm/)
 * (@tsvetanm)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/does-sgo-cache-sitemaps/#post-16090078)
 * Hello [@generosus](https://wordpress.org/support/users/generosus/),
 * The XML sitemaps are excluded from optimizations, but the URLs are still being
   dynamically cached.
 * If you need to exclude certain sitemap URLs from your website being cached you
   can use the exclude filter in SiteGround Optimizer (Exclude URLs from Caching).
 * The filter only accepts wildcard excludes. For example you can exclude the sitemap
   URL as:
    `example.com/sitemap*`
 * Alternatively, you can use the following function in your website code to exclude
   specific URLs from the cache:
 *     ```
       add_filter( 'sgo_exclude_urls_from_cache', 'sgo_add_excluded_urls_from_cache');
       function sgo_add_excluded_urls_from_cache( $excluded_urls ) {
           // The part of the URL which needs to be excluded from cache.
           $excluded_urls[] = '/excluded_url/';
           $excluded_urls[] = '/wildcard/exclude/*';
   
           return $excluded_urls;
       }
       ```
   
 * Currently XML file type is not cached by the NGINX Direct Delivery, but if you
   wish to set a custom TTL for a specific file type, such as XML you will need 
   to disable the NGINX Direct Delivery:
    [https://www.siteground.com/tutorials/supercacher/nginx-direct-delivery/](https://www.siteground.com/tutorials/supercacher/nginx-direct-delivery/)
 * and set the custom expire rule in your website .htaccess using the ExpiresByType
   directive.
 * Best Regards,
    Tsvetan Mitev
 *  Thread Starter [generosus](https://wordpress.org/support/users/generosus/)
 * (@generosus)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/does-sgo-cache-sitemaps/#post-16090161)
 * Hi [@tsvetanm](https://wordpress.org/support/users/tsvetanm/),
 * Perfect. Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Does SGO Cache Sitemaps?’ is closed to new replies.

 * ![](https://ps.w.org/sg-cachepress/assets/icon-256x256.gif?rev=2971889)
 * [Speed Optimizer - The All-In-One Performance-Boosting Plugin](https://wordpress.org/plugins/sg-cachepress/)
 * [Support Threads](https://wordpress.org/support/plugin/sg-cachepress/)
 * [Active Topics](https://wordpress.org/support/plugin/sg-cachepress/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/sg-cachepress/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/sg-cachepress/reviews/)

## Tags

 * [regex](https://wordpress.org/support/topic-tag/regex/)
 * [sitemap](https://wordpress.org/support/topic-tag/sitemap/)

 * 2 replies
 * 2 participants
 * Last reply from: [generosus](https://wordpress.org/support/users/generosus/)
 * Last activity: [3 years, 8 months ago](https://wordpress.org/support/topic/does-sgo-cache-sitemaps/#post-16090161)
 * Status: resolved