本文介绍了如何防止Nancy缓存视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开始以自托管模式测试Nancy.到目前为止,除了让我感到烦恼的一个问题之外,它是如此出色:如何防止它在开发过程中缓存我的视图?

I've started testing out Nancy in self-host mode. So far, so good apart from one issue that's irking me: How do I prevent it from caching my views while developing?

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

I did notice a comment that view caching is supposed to be disabled in Debug mode but it doesn't seem to be working for me - I have to restart my application whenever I make a change to the HTML.

我正在将Nancy 0.10与内置的超级简单视图引擎和.html文件一起使用.

I'm using Nancy 0.10 with the built-in super simple view engine and .html files.

推荐答案

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

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).

请尝试以下

  • 确保您以调试模式进行构建,并检查的值 StaticConfiguration.DisableCaches ,并让我知道它是否为 true 错误
  • 明确尝试将 StaticConfiguration.DisableCaches 设置为 true ,看看它是否停止缓存视图
  • Make sure your are building in debug-mode and check the value ofStaticConfiguration.DisableCaches and let me know if it is true orfalse
  • Explicitly try setting StaticConfiguration.DisableCaches totrue and see if it stops caching your view

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

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

这篇关于如何防止Nancy缓存视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 03:24