1

我对 Express 还很陌生,遇到了问题。我将 node_env 设置为生产,并且 app.get('view cache') 返回 true。但是,它似乎没有缓存我的基于玉的视图。我可以看到 304,但我的视图渲染仍然每次都被调用。

我是否误解了此设置的用途?

编辑:我猜这个设置实际上只是为了让视图模板在生产中表现更好。我是否假设快递不支持动态生成的视图内容的缓存?

我注意到添加 res.header('Cache-Control', 'max-age=60, must-revalidate');

有没有更清洁的方法来做到这一点?谢谢

4

1 回答 1

2

When the 'view cache' setting is true, it caches the compiled javascript of the jade templates.

It doesn't however, cache the jade into a fully static document.

If you wished to do this, you could render the jade once in your app and store the result as a file or in memory. Then you just serve this rendered jade to your client.

于 2013-04-04T17:16:26.343 回答