Skip to content
This repository has been archived by the owner on Jan 24, 2021. It is now read-only.

Avoid compiling Razor views every time an application starts #2998

Open
5 of 8 tasks
PaulBol opened this issue Dec 17, 2019 · 0 comments
Open
5 of 8 tasks

Avoid compiling Razor views every time an application starts #2998

PaulBol opened this issue Dec 17, 2019 · 0 comments

Comments

@PaulBol
Copy link

PaulBol commented Dec 17, 2019

Prerequisites

Description

As mentioned in the thread #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
    • 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
  • .NET Framework version: 4.5.2
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant