Custom sitemap and transient cache

#637309
  • Resolved Massimo
    Rank Math free

    Hi, when I add a custom sitemap with filter rank_math/sitemap/index I see that is added only if I add add_filter( 'rank_math/sitemap/enable_caching', '__return_false');. This is as default or I need to clean a specific transient?

    Best regards

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello,

    Thank you for contacting Rank Math and bringing your concern to our attention.

    Yes, to clear the custom sitemap cache, you’ll have to execute the \RankMath\Sitemap\Cache::invalidate_storage( ‘amp’ ); on save_post hook.

    However, if you’re not sure how to do it, we would recommend you disable the sitemap cache completely by adding the filter you have shared.

    Hope that helps.

    Thank you.

    Massimo
    Rank Math free

    Hi Reinelle, my problem isn’t clean in save_post but add a new sitemap without add the filter to disable cache. I attach my code, maybe I forgot something?

    /**
     * Add new sitemap
     */
    add_filter( 'rank_math/sitemap/index', function( $xml ) {
        $midnight = strtotime("today 00:00");
    
    	$xml .= '
            <sitemap>
    			<loc>'. get_site_url() . '/test-sitemap.xml</loc>
    			<lastmod>' . date('c', $midnight) . '</lastmod>
    		</sitemap>';
    	
        return $xml;
    
    }, 11 );
    /**
     * Add link to sitemap (I've modded this filter)
     */
    add_filter( 'rank_math/sitemap/soci/content', function() {
       return '<url>
          <loc>https://rankmath.com/some-custom-url/</loc>
          <lastmod>2020-06-10T20:20:20+00:00</lastmod>
       </url>';
    }

    Best regards

    Hello,

    If you do not wish to use that filter code to disable file caching of sitemaps, please make sure that your plugins aren’t caching the sitemaps. You may refer to the steps below to do just that:

    1. Flush the Sitemap cache by following this video screencast:
    https://i.rankmath.com/pipRDp

    2. Exclude the Sitemap files of the Rank Math plugin in your caching plugin. The cache could be via a plugin or from the server. For plugins or Cloudflare, please follow this article:
    https://rankmath.com/kb/exclude-sitemaps-from-caching/

    Let us know if that works for you.

    Looking forward to helping you. Thank you.

    Massimo
    Rank Math free

    Thanks Jeremy, that work

    Best regards

    Hello again,

    We are glad to hear that this issue has been resolved. Thank you for letting us know. This ticket will be closed now, but you can always open a new one if you have any other questions or concerns. We are here to help you with anything related to Rank Math.

    We appreciate your patience and cooperation throughout this process.

    Thank you for choosing Rank Math.

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

The ticket ‘Custom sitemap and transient cache’ is closed to new replies.