As we know, Sitecore is one of the most powerful and flexible content management systems available today. It can help to create top-notch brand experiences and serve personalized content that users love. Here are some of the best practices brands must follow to leverage its full potential:
To begin with, website performance is the backbone of a successful business. As a visitor, if I browse your website and there is a delay in loading the webpage, I would like to browse your competitor website. And if for the uninitiated, based on website performance, Google ranks it.
Below are the key points which a developer/architect should follow to improve website performance. We can divide this into different categories:
Coding Practices
Let's look at some of the most significant practices:
Limit the use of GetAncestors and/or GetDescendants API calls - Sitecore recommends limiting the use of GetAncestors and/or GetDescendants API calls as they are known to have performance issues under load.
Limit the use of Sitecore Query - If performance issues occur on controls that use Sitecore query, update the code to use the search index.
Handle Unmanaged Objects - For unmanaged objects, using a loop approach is good for the items below. HtmlTextWriter,MemoryStream, StreamWriter, StringWriter, StreamReader, FileStream ,DbConnection, Stream, HttpWebResponse and WebClient etc
Minimise writing log info - Use log.info only for specific purposes. Also, instead of using log.info, use log.debug and enable the below-mentioned debug mode configuration if required in Sitecore.Logging.config.
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/"> <sitecore> <log4net> <root> <priority value="DEBUG" /> </root> </log4net> </sitecore> </configuration>
By default, the layout engine executes each presentation component for each HTTP request, without any output caching
Enable Static/Dynamic content compression - This helps to boost the performance of the application by reducing the page requests to the server, or by browsing the pages. One can utilize static and dynamic compression in IIS.
When you enable 'IIS static content compression', static responses get compressed and cached on the disk across multiple requests, and without degrading CPU resources. By default, static content compression is enabled in IIS.
var result = query.Select(x => x.GetItem());
public class ApplyInboundIndexStandardValuesFilter : InboundIndexFilterProcessor
{
public override void Process(InboundIndexFilterArgs args)
{
var item = args.IndexableToIndex as SitecoreIndexableItem;
if (item.Item.Name == "__Standard Values")
{
args.IsExcluded = true;
}
}
}
public class ApplyInboundIndexVersionFilter : InboundIndexFilterProcessor
{
public override void Process(InboundIndexFilterArgs args)
{
var item = args.IndexableToIndex as SitecoreIndexableItem;
if (!item.Item.Versions.IsLatestVersion())
{
args.IsExcluded = true;
}
}
}
public class ApplyOutboundNullItemFilter : OutboundIndexFilterProcessor
{
public override void Process(OutboundIndexFilterArgs args)
{
if (args.IndexableUniqueId == null)
{
return;
}
if (args.IndexableDataSource == "sitecore")
{
try
{
var uri = new ItemUri(args.IndexableUniqueId);
var database = Factory.GetDatabase(uri.DatabaseName);
var item = database.GetItem(uri.ItemID, Sitecore.Context.Language);
if (item == null)
{
args.IsExcluded = true;
}
}
catch (Exception ex)
{
}
}
}
}
Sitecore Configuration -
<indexing.filterIndex.inbound>
<processor type="MyWebsite.Search.Pipelines.ApplyInboundIndexVersionFilter, MyWebsite.Search"></processor>
<processor type="MyWebsite.Search.Pipelines.ApplyInboundIndexStandardValuesFilter, MyWebsite.Search"></processor>
</indexing.filterIndex.inbound>
<indexing.filterIndex.outbound>
<processor type="MyWebsite.Search.Pipelines.ApplyOutboundNullItemFilter , MyWebsite.Search" />
</indexing.filterIndex.outbound>
<locations hint="list:AddCrawler">
<crawler type="Sitecore.ContentSearch.SitecoreItemCrawler, Sitecore.ContentSearch">
<Database>web</Database>
<Root>/sitecore/content/Events</Root>
</crawler>
</locations>
<locations hint="list:AddCrawler">
<crawler type="Sitecore.ContentSearch.SitecoreItemCrawler, Sitecore.ContentSearch">
<Database>web</Database>
<Root>/sitecore/content/People</Root>
</crawler>
</locations>
<include hint="list:AddIncludedField">
<BlogTitle>{C56BBA6B-6A5A-4A31-B80F-A3ED88801E54}</BlogTitle>
</include>
From an infrastructure point of view, we should consider the below best practices to get better site performance.
All in all, follow these best practices and see how your website performance is enhanced in no time!
Talk to us about how we bring together 1:1 personalisation, deep Martech Expertise, CX & Demand Gen Strategy, Engagement Analytics & Cross-Channel Orchestration to drive award winning experiences that convert
Get in touch for a complimentary consultation or a demo today.
Free workshops, expert advice & demos- to help your realize value with Sitecore
RegisterParticipate in our event survey , meet us at our booth , get free giveaways & a chance to win an iPhone 11
Let’s go