如何防止Nancy从缓存视图

时间:2012-03-02 13:21:47

标签: c# nancy

我开始以自主模式测试Nancy。到目前为止,除了一个令我烦恼的问题之外,还有这么好:我如何防止它在开发过程中缓存我的观点?

我确实注意到comment视图缓存应该在调试模式下被禁用但它似乎对我不起作用 - 每当我对HTML进行更改时我都必须重新启动应用程序。

我正在使用Nancy 0.10内置超级简单视图引擎和.html文件。

2 个答案:

答案 0 :(得分:5)

默认情况下,在调试模式下禁用缓存 。我唯一能想到的是,在自托管(即非Web项目)中运行时,调试模式检测可能存在错误。

请你试试以下

  • 确保您正在以调试模式构建并检查其值 StaticConfiguration.DisableCaches 并告诉我它是 true 还是 的
  • 明确尝试将 StaticConfiguration.DisableCaches 设置为 true 并查看是否停止缓存您的观点

如果DisableCaches为true,则忽略使用DefaultViewCache类型https://github.com/NancyFx/Nancy/blob/master/src/Nancy/ViewEngines/DefaultViewCache.cs#L30

中的缓存

答案 1 :(得分:0)

TheCodeJunkies answer适用于Nancy 1.x版。

对于Nancy 2.x,<Route path={`/topics/:id`} render={() => <Topic persons={props.persons} />} /> const Topic = (props) =>{ console.log('props are ', props) //logs array of persons return( <div> <h2>Topic</h2> <p>I have been rendered</p> </div> ) } const Topic = ({match}) =>{ console.log('match is ', match) //logs match parameter, but now i can't access persons return( <div> <h2>Topic</h2> <p>I have been rendered</p> </div> ) } 属性处理是否缓存视图。可以在您的runtimeViewDiscovery类中对此进行更改,如下所示:

runtimeViewUpdates