Best practises cheat sheet for your EPi site
- Prefer Controllerless blocks
- Don't Create Content Areas in Blocks, No nesting blocks.
- Minimize database calls. Instead, use Episerver’s caching layer where ever possible.
- Personalization might have an impact on performance, therefore make sure you implement personalization in a way that has the least possible impact.
- Avoid frequent querying of the Dynamic Data Store.
- Try to keep your content tree well balanced.
- Prefer Lists over ContentArea where possible to avoid big content structures for complex pages.
- Avoid dynamic properties.
- Register UIDescriptor, where you disable on page edit and preview views
- For settings kind of pages, ensure that it will not have a template
- Use Episerver’s Object Cache instead of .NET’s built-in cache
- Create all Content Types (Page Types, Block Types, Media Types) in code
- For property (field) names in code, use standard .NET PascalCase. Make sure to set a friendly Display Name and Description
- Plan a data hierarchy for Content Types, and use class inheritance
- Organize groups of properties (fields) into tabs
- Provide an order of properties, with frequently used properties at the top of each tab, Consider Editors
- Set default values for Content Types’ Properties (if known)
- For media properties, use the ContentReference type and the appropriate UIHint
- Use the PropertyFor method to render properties (fields) in Content Type views
- Make sure to always create the appropriate Media Types for assets in the project
- Use Container Pages for folder nodes, without presentation (if required) use IContainerPage.
- Plan carefully the content structure hierarchy, and avoid overloading a single level with too many pages
- Make sure to load-test external systems integrations
- Avoid resolving URLs repeatedly, think about cache.
- Avoid creating blocks to use for image refernces and pages only along with some text as Alt
Disclaimer: Points have been learned from many different sources and experience, have been adding in my best practices document.
Thanks for listing out the checklist for the best practice. I have some questions like
Thanks, and regards
Praful
1- Having Content areas in blocks open a wormhole for nested blocks, I will prefer to avoid by default, will prefer to discuss with the team if it really requires and see if this can be avoided.
2- e.g. Custom Visitor Group Criteria depending on 3rd party services, can secretly effect performance, It will be hard to investigate, should be taken care in advance.
/K
1. I agree. Content Area in blocks might seem like a flexible solution yes. It can however get very difficult for editors and does also have some performance drawbacks. If possible, avoid nesting blocks in blocks except in rare cases. It's like most things. Blocks are great...in moderation.
What do you suggest instead of nested blocks? PropertyList?
Thanks K Khan,
I see now, that using Block may create issue if not used properly. And for personalization, I never know that there are critetia's that may be using a third party service.
KennyG,
https://world.episerver.com/documentation/developer-guides/CMS/Content/Properties/generic-propertylist/
I will just echo Daniel. He explained it well
/K
OMG, we must be twins, Khurram! 😉
Joke aside. I see that some of the key points regarding performance optimizations looks very much like points I very recently wrote on my personal blog (on June 2).
Maybe it is a coincidence, maybe it is copy/paste. But can we please refer or provide links, if we publicly use or refer to the written work of someone else?
You are right, I have added a disclaimer at the end of the blog (as it might cause offence, but I am afraid don't have references for those), This was the collection that I have been collecting from many different resources and was adding in my best practises cheat sheet from many years.
For me above link isn't working, we might be replicating here as generally, we all practise those. Glad you are also sharing your experience and learning.
This site can’t provide a secure connection
stefanolsen.com sent an invalid response.
@Stefan, Looks like your site needs some attention and isn't available to a big audience.
http://stefanolsen.com (Look out! Your Virgin Media Child Safe settings have blocked this site)
https://stefanolsen.com/ (This site can’t provide a secure connection)
https://www.stefanolsen.com/ (This site can’t provide a secure connection)
@Stefan, Looks like your site needs some attention and isn't available to a big audience.
http://stefanolsen.com (Look out! Your Virgin Media Child Safe settings have blocked this site)
https://stefanolsen.com/ (This site can’t provide a secure connection)
https://www.stefanolsen.com/ (This site can’t provide a secure connection)
Just to pick up on KennyG's point, I think the solution to avoiding nested blocks depends on what you're using them for. In some circumstances list properties are absolutely the right option but they also have drawbacks to be aware of in that items aren't reusable (or individually previewable), you can't apply personalisation, localisation is tricky (to put it mildly) and, as it says at the top of the documentation, they aren't officially supported.
One of my pet hates when it comes to nested blocks is to use them just to represent a containing element, for example grouping accordion blocks into an accordion container block. As well as the performance implications, this adds to the work editors have to do to maintain a site. My preferred approach in that scenario is to modify the content area renderer to look for items which should be grouped together (e.g. instances of AccordionItemBlock) and to inject the relevant markup around them.
Hey Paul that's an interesting approach to grouping in the content area renderer. Do you have a blog post or code sample detailing how you do that? I'd like to see that.
I'm afraid I don't have anything written up but, if people would find it useful, I might write up my approach as a blog post. If you're willing to pick through some code, Valdis takes a similar approach in his EPiBootstrapArea project here:
https://github.com/valdisiljuconoks/EPiBootstrapArea/blob/master/src/EPiBootstrapArea/BootstrapAwareContentAreaRenderer.cs
Hey Paul, I see you did write it up! Nice!
For more content related tips, have a look at my post here
Thanks for this useful checklist.
In which scenario using content area will be fine? Do we need to avoid it throughtout?
Thanks for this useful checklist.
In which scenario using content area will be fine? Do we need to avoid it throughtout?
This is a useful list. It would be very helpful to include a "why" statement after each suggestion as well as an alternative solution.