Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does optimizeCompilations in web.config do?

Tags:

c#

asp.net

I've been looking into how to speed up the debug process for my ASP.NET project and have seen a few SO posters talk about setting optimizeCompliations to true. I tried it out and it does seem to make launching a little faster (seemingly), but what exactly does this do and how will it make running my project faster? What "optimizations" are being done to the compilation process?

like image 253
Ryan Thomas Avatar asked Mar 11 '23 18:03

Ryan Thomas


1 Answers

Please check this link: https://blogs.msdn.microsoft.com/davidebb/2009/04/15/a-new-flag-to-optimize-asp-net-compilation-behavior/

I believe it clear explains what this is:

ASP.NET uses a per application hash code which includes the state of a number of things, including the bin and App_Code folder, and global.asax. Whenever an ASP.NET app domain starts, it checks if this hash code has changed from what it previously computed. If it has, then the entire codegen folder (where compiled and shadow copied assemblies live) is wiped out.

When this optimization is turned on (via <compilation optimizeCompilations="true" />), the hash no longer takes into account bin, App_Code and global.asax. As a result, if those change we don’t wipe out the codegen folder.

Of course, if App_Code or global.asax have changed, they get rebuilt. But pages that have been previously compiled don’t (unless they have themselves changed).

Note that this optimization doesn’t affect the app domain shutdown behavior. i.e. we still shut down the domain as soon as any top level file changes. It’s only the amount of compilation in the new domain that is affected.

like image 188
charles Avatar answered Mar 31 '23 10:03

charles