Hi @mapdi
can you please add from which plugin this sitemap is coming?
We already skip the cache for the core sitemaps:
https://github.com/pluginkollektiv/cachify/issues/242
https://github.com/pluginkollektiv/cachify/pull/254
For skipping the sitemap caching for the Google XML Sitemaps plugin you can use our filter cachify_skip_cache
as seen here:
https://github.com/pluginkollektiv/cachify/issues/60#issuecomment-335106482
If we know which plugin is generating this Sitemap we will find a way to skip it with the before mentioned method.
All the best
Torsten
Thread Starter
mapdi
(@mapdi)
Hi @zodiac1978
Thank you.
We use the Rank Math plugin to create the sitemap xml file. https://wordpress.org/plugins/seo-by-rank-math/
So if I understand this correctly I would have to exclude the xml file (sitemap_index.xml) via hook?
/*
* Cachify: Do note cache XML Sitemap Rank Math
*/
if (defined('CACHIFY_FILE')) {
add_filter(
'cachify_skip_cache',
function() {
global $wp_query;
return !empty($wp_query->query_vars["sitemap_index"]);
}
);
}
Best regards
mapdi
Hi @mapdi
we need to check for the correct query_var
.
For Google XML Sitemap this is defined here:
https://github.com/Auctollo/google-sitemap-generator/blob/dbca6fc9b9dd8cd0cd9e63758650d3f727d99683/class-googlesitemapgeneratorloader.php#L104-L114
And the rewrite rules are defined after that.
Now we need to look which query_var
RankMath is using. Looks like this is defined here:
https://github.com/rankmath/seo-by-rank-math/blob/eea089f0afe7f476d1f9dadc1a9f75377373d282/includes/modules/sitemap/class-router.php#L40-L54
So I would try one of those three query_vars
. Maybe sitemap_n
:
/*
* Cachify: Do note cache XML Sitemap Rank Math
*/
if (defined('CACHIFY_FILE')) {
add_filter(
'cachify_skip_cache',
function() {
global $wp_query;
return !empty($wp_query->query_vars["sitemap_n"]);
}
);
}
Can you please try this and report back if this works?
Thanks in advance!
All the best
Torsten
Thread Starter
mapdi
(@mapdi)
Thank you very much.
At the moment it seems to work. But I will report here as soon as it doesn’t work properly anymore.
With kind regards!