Stay up to date with weekly industry insights

the latest trends in web design, inbound marketing, mobile strategy and more...

3 Methods for Improving Your Page Speed with Episerver

three-methods-for-improving-your-page-speed-with-episerver.jpg

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. How have you improved your page speed with Episerver? Let us know below!

About the Author

Dustin Sier
Dustin Sier
Dustin is a Web Developer at WSOL. He helps our clients to develop robust solutions that meet their business needs. He is an Ektron and EPiServer MVP, and he won an Outstanding Contributor Award from Ellucian in 2014 for work in their Luminis community. He was a presenter at the 2014 Ektron Synergy and Ellucian Live conferences. Dustin’s hobbies include space, particularly astronomy/astrophysics, and philosophy, as well as dabbling in farming.