Geta / geta-optimizely-sitemaps

Search engine sitemaps.xml for Optimizely CMS 12 and Commerce 14
Apache License 2.0
10 stars 14 forks source link

Sitemap data is cached forever with no option to clear it #78

Open tomaszmadeyski opened 1 year ago

tomaszmadeyski commented 1 year ago

With the following values in the configuration:

services.AddSitemaps(x =>
{
      x.EnableLanguageDropDownInAdmin = true;
      x.EnableRealtimeCaching = true;
      x.EnableRealtimeSitemap = true;
});

sitemap data is being cached forever due to the fact that the CacheEvictionPolicy is set to null (if I'm not a googleBot):

https://github.com/Geta/geta-optimizely-sitemaps/blob/master/src/Geta.Optimizely.Sitemaps/Controllers/GetaSitemapController.cs#L109

var cachePolicy = isGoogleBot
            ? new CacheEvictionPolicy(TimeSpan.Zero,
                                      CacheTimeoutType.Sliding,
                                      new[] { _contentCacheKeyCreator.VersionKey })
            : null;
CacheManager.Insert(cacheKey, sitemapData.Data, cachePolicy);

I think it would be reasonable to cache it for some limited period - maybe 1 day or maybe 1 day by default with an option to overwrite this value in configuration?