How to Prevent Nancy From Caching Views
Caching is disabled by default in debug-mode. The only thing I can think of is that there might be a bug on the debug-mode detection while running in a self-host (i.e a non web-project).
Could you please try the following
- Make sure your are building in debug-mode and check the value of StaticConfiguration.DisableCaches and let me know if it is true or false
- Explicitly try setting StaticConfiguration.DisableCaches to true and see if it stops caching your view
If DisableCaches is true then it ignores to use the cache in the DefaultViewCache type https://github.com/NancyFx/Nancy/blob/master/src/Nancy/ViewEngines/DefaultViewCache.cs#L30
TheCodeJunkies answer works for version 1.x of Nancy.
For 2.x of Nancy the runtimeViewDiscovery
and runtimeViewUpdates
properties handle if views are cached or not. This can be changed in your NancyBootstrapper
class, like so:
public class NancyBootstrapper : DefaultNancyBootstrapper
{
public override void Configure(INancyEnvironment environment)
{
base.Configure(environment);
environment.Views(runtimeViewDiscovery: true, runtimeViewUpdates: true);
}
}