Sailsjs view caching (bug ?)

一世执手 提交于 2019-12-11 04:17:42

问题


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

Peculiar Behaviour:

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

BUT

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

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

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.

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

回答1:


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.



来源:https://stackoverflow.com/questions/28294429/sailsjs-view-caching-bug

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!