Why do my asp.net views take so long to render?
I’ve optimized my database queries with indexes and am caching output for 10 minutes at a time, but occasionally I have to recalculate the page, and it’s taking way longer than I like. Tools like firebug only show that the request spent a long time waiting on the server. What I really need is a tool to help me locate the bottleneck.
This image shows that the total time to render the page was 478ms. Of that, 351ms was spent server-side, and 198ms of that was on rendering the view. That means not the database access, but compiling the cshtml with embedded C# at runtime.
How to reduce that render time? Precompile the views at build time!
Now that the views are precompiled, our page render time has dropped to 208ms, with only 72ms spent server side. At 208ms, page loads feel almost instant, which only happens when we have a cache miss once every ten minutes.