1
Vote

Why first request still very slow??

description

I'm look at the article: http://stacktoheap.com/blog/2013/01/19/precompiling-razor-views-in-asp-dot-net-mvc-3/

and add the new version Razor generator Extends on visual studio 2012, I'm also add Nuget packege:RazorGenerator.mvc and RazorGenerator.MsBuild to my mvc4 project.

I find there is auto add a class, and it can auto execute when application start debug.
public static class RazorGeneratorMvcStart {
        public static void Start() {
            var engine = new PrecompiledMvcEngine(typeof(RazorGeneratorMvcStart).Assembly) {
                UsePhysicalViewsIfNewer = HttpContext.Current.Request.IsLocal
            };

            ViewEngines.Engines.Insert(0, engine);

            // StartPage lookups are done by WebPages. 
            VirtualPathFactoryManager.RegisterVirtualPathFactory(engine);
        }
But I'm not changed anything, the new version Something different with the article . like RazorGenerator.targets , So I don't changed anything.

and I also not add the RazorGenerator content to custom tools of .csthml file property, because the artile not like me use it . But when I debug , every thing fine , there is .cs file auto generate on obj/ folder all from Razor view.

I also add this on my .csproj file like the article said:
Target Name="BeforeBuild">
    <ItemGroup>
      <Content Remove="Views\**\*.cshtml" />
      <None Include="Views\**\*.cshtml" />
    </ItemGroup>
  </Target>
and I publish my project use visual studio vs2012(remove recompile option on the publish)

and use IIS open . but ....the first request still very slow.......

Am I miss or the new version some changed? the view can normal open, but why the first request still slow?

specially when first request(not access view still very slow).

Why can't let the all class loading when the IIS start the website??

thanks , and sorry for my bad english.

comments

davidebbo wrote Mar 24 at 5:19 PM

There are lots of other things that need to happen when a site starts beyond compiling views, like loading a lot of assemblies from bin, and running whatever other startup logic. RazorGenerator eliminates the on-the-fly compilation of views, but it may not solve all perf issues.

qakmak wrote Mar 26 at 4:39 PM

@davidebbo So Is there any way to let it more fast please?

davidebbo wrote Mar 26 at 5:21 PM

If you can verify that your views are correctly getting precompiled, then RG is doing its part. Any addition perf improvement is beyond the scope of this forum, and best discussed in general ASP.NET MVC forums or StackOverflow.

qakmak wrote Mar 27 at 7:14 AM

@davidebbo Ok, thanks.

msmolka wrote Apr 11 at 9:33 AM

I have similar issue, but it is not related to Razorgenerator but to IIS.
First of all check asp compiler; when you are using Publish and precompilation it compiling as x86. And it cannot be changed. MS Connect issue states -> cannot be repaired. So if you use x64 then you need precompile web from some kind of batch scripting.

Second of all, even if application is precompiled, IIS still makes some internal precompilation and put that compiled to its own temp folders, that are cleared on start or recycle.

I solved long start issue by changed Web Pool to x32 because starting it on x63 cause so big memory peek thet ended with out of memory exception even for quite small web site. This is ridiculous, but I didn't find the way how to solve this other way.