As mentioned in the thread https://github.com/NancyFx/Nancy/issues/2866 compiling Razor views takes time. With the latest package from Nuget I found that launching the compiler for the first view takes 3-4 seconds and each additional view needs around 50 ms to compile.
This is an issue for a Nancy server in an application that users launch and expect to work with as quickly as possible. I understand that with the current Nancy architecture Razor views need to be compiled after each start of an application.
To ensure that a desktop application starts as quickly as possible I came up with a workaround that involves calling GetOrCompileView by reflection and a IViewCache implementation which writes the compiled assemblies to disk and loads them on subsequent starts. Rather hacky to say the least.
What I would like
Get some feedback if there is a more straightforward way to avoid repeated view compilation
If there is none, have better support in the Nancy framework for caching compiled Razor views
Steps to Reproduce
Create project with Nancy.Hosting.Self.NancyHost and RazorViewEngine with a route returning a Razor view
Start application
Open page in browser -> takes several seconds to respond
System Configuration
Nancy version: 2.0.0 (Nuget)
Nancy host
[ ] Nancy.Hosting.Aspnet
[X] Nancy.Hosting.Self
[ ] Nancy.Owin ()
[ ] Other:
Other Nancy packages and versions: Nancy.ViewEngines.Razor 2.0.0
Environment (Operating system, version and so on): Windows 10
Prerequisites
DEBUG
andRELEASE
modeDescription
As mentioned in the thread https://github.com/NancyFx/Nancy/issues/2866 compiling Razor views takes time. With the latest package from Nuget I found that launching the compiler for the first view takes 3-4 seconds and each additional view needs around 50 ms to compile.
This is an issue for a Nancy server in an application that users launch and expect to work with as quickly as possible. I understand that with the current Nancy architecture Razor views need to be compiled after each start of an application.
To ensure that a desktop application starts as quickly as possible I came up with a workaround that involves calling
GetOrCompileView
by reflection and aIViewCache
implementation which writes the compiled assemblies to disk and loads them on subsequent starts. Rather hacky to say the least.What I would like
Steps to Reproduce
Nancy.Hosting.Self.NancyHost
andRazorViewEngine
with a route returning a Razor viewSystem Configuration