设置 node_env=production 是否处理条件模板?

Does setting node_env=production handle conditional templates?

我在 keystone 中使用了很多 nunjucks 模板和自定义 api 端点。是否设置 node_env=生产缓存模板 return 数据,特别是因为它有很多动态信息。它是缓存渲染的还是只是模板文件?此外,自定义 /api 端点如何......假设数据未缓存?数据库结果如何?感谢您提供任何信息。

NODE_ENV 设置是一个 Express 约定,因此效果适用于 Express 和相关中间件而不是 Keystone 核心。如果您添加了任何 Express 中间件包,则必须检查它们的使用文档以了解可能的行为更改。

Setting NODE_ENV to “production” 使快递:

  • 缓存视图模板。
  • 缓存 CSS 由 CSS 扩展生成的文件。
  • 生成更简洁的错误消息。

I am using a lot of nunjucks templates and custom api endpoints with keystone. Does setting node_env=production cache template return data, especially since it has a lot of dynamic info. Does it cache the rendered or just template file?

Express 只在内存中缓存视图模板,不缓存渲染结果。页面仍将根据使用相关变量的每个请求重新呈现。在 Express 的 Using Template Engines 文档底部有一条关于此的说明。

what about custom /api endpoints ... assuming that data is not cached?

Express 默认不包含 API 端点的任何缓存。

How about database results?

MongoDB Node.js 驱动程序(和 Mongoose ODM)不缓存查询结果。