Geta.Optimizely.Sitemaps - 'Generate search engine sitemaps' job takes hours to complete

Vote:
 

Using Geta.Optimizely.Sitemaps 3.1.2 we see our sitemaps created with the 'Generate search engine sitemaps' job. But the job takes almost 7 hours to complete. Before we upgraded Episerver nuget packages back in May, we saw the job take about an hour to complete.

Anyone else noticed an increase in time to complete the job?

We upgraded FROM:

EPiServer.CMS 12.28.0
EPiServer.Commerce 14.19.0

TO:

EPiServer.CMS 12.29.1
EPiServer.Commerce 14.21.0

#326335
Jul 31, 2024 18:53
Vote:
 

It is usually not that big. Were you able to debug to see what is happening?
I think you can override SitemapController > Index routing

#326613
Aug 06, 2024 12:39
Mike Malloy - Aug 07, 2024 19:49
I have not. Do you have an example of the override?
Vote:
 

You can override to see what's happening. Here is an example of our implementation, In our case we had two sites to take care of. Hence differentiating based on StartPage.ID. See more in Generate method.

[Route("sitemapindex.xml")]
public class MultisiteGetaSitemapIndexController : BaseController
{
    private readonly ISitemapRepository _sitemapRepository;

    public MultisiteGetaSitemapIndexController(ISitemapRepository sitemapRepository)
    {
        _sitemapRepository = sitemapRepository;
    }

    private static XNamespace SitemapXmlNamespace
    {
        get { return @"http://www.sitemaps.org/schemas/sitemap/0.9"; }
    }

    [Route("", Name = "Sitemap index")]
    [HttpGet]
    public new IActionResult Index()
    {
        // Call the Generate method when accessing sitemapindex.xml
        return Generate();
    }

    [HttpGet(nameof(Generate))]
    public IActionResult Generate()
    {
        var doc = new XDocument(new XDeclaration("1.0", "utf-8", null));

        var indexElement = new XElement(SitemapXmlNamespace + "sitemapindex");

        foreach (var sitemapData in _sitemapRepository.GetAllSitemapData()
                     .Where(x => x.RootPageId == ContentReference.StartPage.ID))
        {
            var sitemapElement = new XElement(
                SitemapXmlNamespace + "sitemap",
                new XElement(SitemapXmlNamespace + "loc", _sitemapRepository.GetSitemapUrl(sitemapData)));

            indexElement.Add(sitemapElement);
        }

        doc.Add(indexElement);

        byte[] sitemapIndexData;

        using (var ms = new MemoryStream())
        {
            using (var xtw = new XmlTextWriter(ms, Encoding.UTF8))
            {
                doc.Save(xtw);
                xtw.Flush();
                sitemapIndexData = ms.ToArray();
            }
        }

        return new FileContentResult(sitemapIndexData, "text/xml");
    }
}
#326723
Aug 08, 2024 12:03
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.