Skip to main content

Checkup Documenation

Recompiles before app restart (.NET code)

severity-low code-web-config-default-numRecompilesBeforeAppRestart

Summary

The numRecompilesBeforeAppRestart does just what the name would imply. It sets the number of dynamic recompiles of resources that can occur before the application restarts. It is important this is set correctly as having the numRecompilesBeforeAppRestart setting set too low can cause unnecessary recompiles of your site which will negatively impact your page speed and possibly cause site downtime. In this check, we are looking at your root web.config's system.web/compilation node for this attribute. It is simply checking to see if it is the default value.

If your site contains many non-pre-compiled files such as WebForms code-behind page files (*.aspx.cs) or MVC Razor views (*.cshtml), you might run into a problem of continuous application restarts. The default value for a normal project is 15 (in a Kentico Xperience project, the default is 100). If you update files and reach this number, your application will perform a restart (potentially multiple restarts). 


Check Logic

Constant Care for Kentico will ensure the numRecompilesBeforeAppRestart attribute in the web.config is greater than 100 (default)

You can manage your settings for this checkup in the Constant Care for Kentico admin settings.


Resolution

This check is in place to simply inform you that we found the default, out-of-the-box value. It doesn't mean this points to an issue, it just means it most likely was not intentionally set to an optimal value. Typically, higher values are better than lower values, but it really depends on your site and server.

If you have too many application restarts happening on your site, then increasing the value will solve the application restarts. However, it will add more memory consumption by your application. This might be just fine (if you have the memory). Finding the right value for this property depends on the number of non-precompiled files your web application or website has and how much RAM you want to use on your server.

This is one of those settings that you may want to talk to your Kentico Xperience Gold Partner about.

To find this setting you will need to look in your root web.config file for the following code.

After deciding what an optimal setting is, you can update your web.config file. If you feel that 100 is the right value for your site (which is absolutely possible). Then you could update your check settings so it will alert you if it is less than 99.

For more information on this setting please visit Microsoft's documentation here:

https://docs.microsoft.com/en-us/dotnet/api/system.web.configuration.compilationsection.numrecompilesbeforeapprestart?view=netframework-4.8

https://msdn.microsoft.com/en-us/library/s10awwz0(v=vs.71).aspx

Not sure what to do?

If you are ever unsure about making changes to your site, we encourage you to reach out to your Kentico Xperience Gold Partner. If you do not have a partner, then feel free contact the Constant Care For Kentico team to get connected with an expert.