I'm using a self-hosted Nancy with Spark templates. I've disabled the cache specifically (though in DEBUG is should be disabled by default).
protected override void ApplicationStartup(Nancy.TinyIoc.TinyIoCContainer container, IPipelines pipelines)
{
base.ApplicationStartup(container, pipelines);
...
StaticConfiguration.Caching.EnableRuntimeViewDiscovery = true;
StaticConfiguration.Caching.EnableRuntimeViewUpdates = true;
}
However, making changes to the templates while the app is running doesn't seem to work, as the template changes are not picked up.
Is there anything else required to disable views caching?
Ok, managed to get this to work by adding a custom
ViewCachein the bootstrapper:The new
ViewCachejust reloads the template on every request:Somehow the
viewLocationResult.IsStale()was always returningfalse.By default, this is an instance of
FileSystemViewLocationResultwhich just compares the last update time of the view, but the timestampthis.lastUpdatedwas being updated before callingIsStale()from theDefaultViewCache, so the template was never removed from the cache