Hundreds of renderings? Your first-page-load could be sloooow

In this post

Having many subfolders of MVC views could impact page-load time.

Helix-style Feature folders

In a Helix-style solution, it’s common to group your MVC views by feature:


Large solutions may see 50, 60, 70+ MVC views making up a single page. If these views are in separate subfolders, we’ve noticed a performance penalty.

Just Helix-style solutions?

No, definitely not. Any solution with many views in many subfolders. Sitecore or no-Sitecore.

When will this affect me?

Each time you deploy to a new folder (ie, D:\Web\Octopus-\), a new Temporary ASP.NET Files folder is populated with JIT-compiled versions of your .cshtml files. Typically you can see slow first-page-load times after a new deployment.

The technical details

Shout out: Oleg Volkov’s blog details what is going on here: Thanks, Oleg!

The System.Web.Compilation.BuildManager class (,1662) contains a method, CompileWebFile(..), which JIT compiles your .cshtml files. In a handy performance boost, CompileWebFile(..) will batch this compilation, working on an entire directory at a time. This means that having 100 views in a single directory will compile a lot faster than having 100 views in 100 directories.

How much slower?

We did some strikingly unscientific testing by including 400 Partial Views on a page.

400 Views in 1 Folder

  • Create new directory, deploy to this directory
  • IIS Reset
  • First page load: 58s

400 Views in 40 Folder

  • Create new directory, deploy to this directory
  • IIS Reset
  • First page load: 3m26s

What’s the solution?

We went with MVC View precompilation (using because moving all .cshtml files to a single directory wasn’t a viable option. This brings the compilation time back down for us, and first-page-load after a deployment is now under 1 minute (previously 7+!).


4 thoughts on “Hundreds of renderings? Your first-page-load could be sloooow

  1. You can also create your own view engine which uses Roslyn compiler (there are examples on Stackoverflow that shows how to compile code using Roslyn). I did exactly that in in-house CMS I built. Result? Standard compilation on average would take over 2 seconds per view. With Roslyn compilation went down to 180 milliseconds. To speed increase is massive!!!


  2. Pingback: An interesting side effect of compiled views | Jeremy Davis

  3. Pingback: Beware of View Compilation with Helix Features! - Living life in .NET and Sitecore

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s