FeaturesViewEngine with caching

Last December I have published a library - FeaturesViewEngine which enables feature folder support. It had one drawback - it did not use caching. Now I have released a new version with caching enabled.

Short release info

Thanks to my colleague's - Kaspars Ozols suggestions, I have made changes to the FeaturesViewEngine. The blog post about its configuration is still up to date, and there are no breaking changes. The changes improve view resolution performance.

You can install the new version from NuGet:

Install-Package FeaturesViewEngine -Version 1.1.0

You can find the source code on GitHub.

Some technical stuff

Previously, I overrode a CreateView method of the base RazorViewEngine. When a cache was enabled, the CreateView method was called only once for a particular view name. As controllers can have similar view names, it always resolved the first view. The cache didn't use controller data for cache key - only view name. So cache had to be disabled.

In the latest version, I overrode a FindView (and FindPartialView) method instead. This method is always called and uses caching internally. I also had to pass the full virtual path to the base method. For that, I had to check for the first existing view matching particular controller and view location format. Once the view's full path is resolved, it is cached.