<img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=1639164799743833&amp;ev=PageView&amp;noscript=1">
Diagram Views

3 Methods for Improving Your Page Speed with Episerver

Dustin Sier
#Episerver, #Digital Strategy
Published on January 3, 2018
warren-wong-323107-unsplash-1

We’ve all been there. We’ve got this immaculate website built out and ready to show to a client. It’s beautiful, it's intuitive…and it takes 30 seconds to load.

We’ve all been there. We’ve got this immaculately designed and orchestrated site built out and ready to show to a client. It’s beautiful, it's intuitive…and it takes 30 seconds for the page to load. That’s not good! Thankfully, Episerver provides some great things to help out of the box. This makes it easy to implement the strategies we’ve mentioned in the past and allows for other methods to help in improving page speed performance.

1. Episerver caches pages by default

Welcome to the easy world where Episerver automatically implements the caching of objects tied to page and block types. Any property that is maintained via the Episerver editor interface is already cached and updated as-needed by the system. No special help needed there for you!

2. Episerver gives you fine grained control over static file caching

Turns out, static file caching is already setup, enabled, and controlled via configuration settings in your application. You can manually determine the expiration time for any static file. Details can be found on the Episerver World site.

3. Be careful with calculated fields!

Calculated fields are those things that are determined or calculated at run time. Generally, it’s a good idea to avoid using calculated fields in Episerver page definitions. Instead, I would recommend using ViewModels for any calculated field. This helps you separate your concerns and more easily triage any errors that pop up. In the case of most calculated fields, implementing a caching strategy to handle those calculated fields. This can really help with page load and page speed issues. This is even true when you’re using default Episerver APIs. Here’s an example:


	
private EPiServer.IContentRepository _contentRepository = ServiceLoca-tor.Current.GetInstance();

private IEnumerable FindReferences(PageData page)
{
    string cacheKey = string.Format("FindReferences:{0}", page.ContentLink.ID);
    IEnumerable pageReferences;

    if (!_objectCache.TryGet<ienumerable>(cacheKey, ReadStrategy.Wait, out pag-eReferences))
    {
        var references = _contentRepository.GetReferencesToContent(page.ContentLink, true).ToList();

        pageReferences = references.Select(x => _contentRepository.Get(x.OwnerID));


        _objectCache.Insert(
            string.Format(cacheKey, page.ContentLink.ID),
            pageReferences,
            new CacheEvictionPolicy(new TimeSpan(10), CacheTimeoutType.Absolute)
        );
    }



    return pageReferences;

}


	

 

Page speed in Episerver turns out to be easy. The default CMS provides excellent caching around user managed entries and with some simple caching steps, you can increase even the most troublesome pages with calculated fields. 

Is Episerver website not performing well? 

Let's Discuss It