Hi @cybr,
Sorry for the delayed reply due to the festive season here.
That rule causes NGINX to expect a valid static XML file to be located on the server, which isn’t the case with PHP-generated XML output.
– Thanks for joining this conversation. That rule tells NGINX that IF there is a static XML or XSL file then to use that cache-control
header – that’s it. But if there is no static file then that won’t get invoked.
Moreover, both Yoast SEO and Rankmath uses the dynamic PHP based sitemap generation approach and this issue is not present despite having that rule in the NGINX.
If it still works on your site, even with that rule in place, you’re probably using a specific override of the rule that redirects the sitemap endpoint back to the PHP engine.
– Maybe, but not sure of that as I’m not personally aware of any such overwrite rules.
Cause Rankmath ask users to add a specific NGINX rule for their system to work. Example:
# START Nginx Rewrites for Rank Math Sitemaps
rewrite ^/sitemap_index.xml$ /index.php?sitemap=1 last;
rewrite ^/([^/]+?)-sitemap([0-9]+)?.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;
# END Nginx Rewrites for Rank Math Sitemaps
So, maybe that’s overwriting as you stated above.
Anyways, if that rule is causing any problem, you can definitely comment it if you feel so.
—————–
Now coming to your question @allnamestaken,
you should ask your sitemap generator plugin developer if there is any filter or way to set the cache-control
header value of the sitemap files to no-cache, no-store, must-revalidate, max-age=0
. That will tell Cloudflare not to cache the sitemap pages.