website crash after add snippet to .haccess to exclude the sitemap caching

  • Hi,

    Could you please let me know how to exclude the sitemap from caching without breaking the website. I am using wp3 total cache right now.

    After following your document which is located at this link, My web crashed. I can figure out what is the real reason behind because the issues can be many. Sometimes the links come with 502 bad gateway error, sometimes comes with blank page, or messy coding-wording layout.

    I have contacted my hosing (cloudways). their staff tried to help me a lot, including debug, check the error log, even disable the cloudflair. Unfortunately, we can not find any reason.

    Could you please advise how to avoid this issue if using WP3 total caching. If we purchase WP rocket, that would be more compatible with your plugin or easier for setting up, therefore avoiding the issue of sitemap caching? Anyway, I am not happy with the result of Wp3 total caching which has not dramatically improve the web speed, so do not mind purchasing WP rocket.

    Best regards

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

    Thank you for contacting Rank Math and sorry for any inconvenience caused.

    Please add this filter in the theme’s functions.php file:

    add_filter( 'rank_math/sitemap/enable_caching', '__return_false');

    Here is a guide you can follow to add the filter:

    Once done, clear your website cache and check the sitemap.

    Let us know if the issue persists.

    We are here to assist you.

    Hi, Anas

    Really appreciate your quick response. The above snippet has been added on my web.

    My question is that except for this snippet given by you, need I to do the same thing following your document at My guess is “No”.

    I will keep looking at the sitemap in the google search console to see if the above snippet is working or not.



    When you add that code snippet you shouldn’t need to do anything else to get the sitemaps not being cached.

    You can check the same the next time you create a new post or page you can check the sitemap immediately after that and see if the page/post appears there.

    Don’t hesitate to get in touch if you have any other questions.

    Hi, Team

    I think the issue was resolved, but another big issue comes out. I have submited two new tickets about my sitemap could not fetch and it seems they have not been submitted successfully.

    Our sitemap was running pretty good, but today, the sitemap suddenly shows “could not fetch” error. We did everything as below:

    1. following your document located here. Resubmited sitemaps many times. But failed and the issued can not resolved.

    2. Use validation tool to check the sitemap It shows: no issues detected.

    3. Contact our hosting (cloudways) to double check if our sitemap has been blocked by our robots.txt. The result is “all good, no block”

    4. We are using Nitropack caching and sitemap has been excluded from cache


    We have replied to your other ticket for the same issue and closing this one.


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

The ticket ‘website crash after add snippet to .haccess to exclude the sitemap caching’ is closed to new replies.