Sailsjs视图缓存(错误?) [英] Sailsjs view caching (bug ?)

查看:64
本文介绍了Sailsjs视图缓存(错误?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 res.view('layout',{my:'Object'})视图 >。

I was rendering a view using res.view('layout', {my: 'Object'}).

特殊行为:

当我更改 ejs 文件并刷新浏览器,更改可见(无需重新启动服务器)。

When I changed the ejs file and refreshed the browser, the change was visible (without server restart).

BUT

如果我的对象包含属性 cache truthy 值,如下所示:

If my object contained a truthy value of property cache, like so:


res.view('layout',{my:'Object',cache:true})

然后,我在浏览器中打开视图,一切都很好。但是,如果我现在更改 ejs 文件,除非服务器停止并重新提起,否则更改不会在刷新时显示在浏览器中。

then, I open the view in the browser, all's good. But if I change the ejs file now, the changes do not show in the browser on refresh, unless server is stopped and re-lifted.

我错过了与此相关的 sailsjs 的任何文档吗?还是 express framework或 ejs 还是一个bug?

Is there any documentation of sailsjs about this that I missed, or is this part of express framework or ejs or is it a bug ?

SailsJs v0.10.5
NodeJs v0.10.33


推荐答案

通过将 cache 选项设置为 true 激活 ejs 缓存。这是 ejs 混合使用其视图局部变量和选项的不幸副作用。如果您打算使用名为 cache 的本地视图,则必须将其命名为 _cache 或其他名称。有关所有可能选项的列表,请参见 ejs文档

You are activating ejs caching by setting the cache option to true. This is an unfortunate side effect of ejs mixing its view locals and options together. If your intention was to have a view local named cache, you'll have to name it _cache or something. See the ejs docs for a list of all possible options.

这篇关于Sailsjs视图缓存(错误?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆