Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

Razor is not caching results for views that don't exist #2796

Closed
rynowak opened this issue Jul 9, 2015 · 4 comments
Closed

Razor is not caching results for views that don't exist #2796

rynowak opened this issue Jul 9, 2015 · 4 comments

Comments

@rynowak
Copy link
Member

rynowak commented Jul 9, 2015

Nothing is cached when looking for a view that doesn't exist, causing us to repeat the file lookup each time it's requested.

This is a big problem when using EditorFor because the default templates are frequently requested and rarely customized. Here's the offending code:
https://github.com/aspnet/Mvc/blob/dev/src/Microsoft.AspNet.Mvc.Razor/Compilation/CompilerCache.cs#L108

Suggestion from @pranavkm is to fold this case into OnCacheMiss and make that method capable of storing data about a file that doesn't exist on disk.

@davidfowl
Copy link
Member

You don't want this to be unbounded righ? What misses do we want to cache? Also what did mvc 5 do?

@pranavkm
Copy link
Contributor

pranavkm commented Jul 9, 2015

We had a bit of caching using the IVirtualPathPageFactory but it was short-lived. In our case, we would cache a null result along with a file watch on that specific path.

@rynowak
Copy link
Member Author

rynowak commented Jul 9, 2015

You don't want this to be unbounded righ?

@davidfowl - this isn't based on user input, it's based on pages that the app is programmed to render. In a properly programmed app there will still be lots of misses that aren't errors due to display/editor templates. In the case of editor/display templates, the bounding factor is the number of types used in views.

This bug means we go to disk for every @Html.EditorFor

@danroth27 danroth27 added this to the 6.0.0-beta7 milestone Jul 16, 2015
@danroth27 danroth27 assigned rynowak and pranavkm and unassigned rynowak Jul 16, 2015
pranavkm added a commit that referenced this issue Aug 5, 2015
* Allow precompiled views to be served when source file does not exist in
  file system.
* Cache results for views that do not exist on disk.

Fixes #2462 and fixes #2796.
Partially addresses #2551
@rynowak
Copy link
Member Author

rynowak commented Aug 7, 2015

😻

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants