奇怪的快速Jade视图caching行为

刚刚更新我的Node.js和Express版本分别为0.10.21和3.4.4,现在我看到一些奇怪的视图caching在开发(和生产)。

看起来从其他视图(或者所有视图?)中包含的视图生成的html被caching。

例如:

layout.jade

doctype 5 html head title= title meta(name="viewport", content="width=device-width, initial-scale=1.0") link(rel='stylesheet', href='/stylesheets/style.css') body #container include header block content include footer 

header.jade

 - var headerClass = "" if pageVars.headerOverBackground - headerClass = "overbackground" #header(class=headerClass) [snip] 

somepage.jade

 extends layout block content [snip] 

我第一次调用/ somepage ,传递pageVars.headerOverBackground设置为true,视图呈现正确。 如果我使用相同的布局和页眉访问不同的URL / someotherpage ,传入pageVars.headerOverBackground设置为false,我仍然可以看到header.jade部分呈现,就像它在上一页(与“overbackground”类在#header上),就像pageVars.headerOverBackground仍然是一样的。

但是这是错误的,我有console.log()来certificate它。

难道我做错了什么? 我只是非常困惑? 我已经在开发和生产模式中运行Node,甚至还用Express来运行它

 app.disable('view cache'); 

无济于事…

编辑:

无论我重新加载页面多less次,它都会加载caching的视图。 如果我重新启动节点并重新加载,则显示正确的视图。

好吧,我想我可能已经解决了这个问题。

其中一条路线错误了

 pageVars = {}; 

代替

 var pageVars = {}; 

导致声明一个全局variables。 哎呀! 而在旧版本的Node / Express / Jade和当前版本之间,Jade开始更喜欢全局variables,即使明确地传递了同名的本地variables。

所以如果一条路线错误的话

 pageVars = {}; //global, oops pageVars.headerOverBackground = true; res.render("onepage", {pageVars:pageVars}); 

然后调用另一条路线

 var pageVars = {}; //local // pageVars.headerOverBackground is undefined res.render("anotherpage", {pageVars:pageVars}); 

另一个视图中的玉将使用pageVars的全局版本,而不是传递的局部variables,并且仍然认为pageVars.headerOverBackground为true。