From 4381b3f64d07f259cf972e4724d0c1765f72e513 Mon Sep 17 00:00:00 2001 From: Ethan Mills Date: Mon, 5 Feb 2024 11:40:42 +0000 Subject: [PATCH] ATO-459: cache nunjucks templates This should reduce disk iops and improve overall performance when rendering templates. --- src/config/nunchucks.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/config/nunchucks.ts b/src/config/nunchucks.ts index 23a02dc66..6457799c5 100644 --- a/src/config/nunchucks.ts +++ b/src/config/nunchucks.ts @@ -3,6 +3,8 @@ import * as nunjucks from "nunjucks"; import { Environment } from "nunjucks"; import i18next from "i18next"; import { returnLastCharactersOnly } from "../utils/phone-number"; +import { getNodeEnv } from "../config"; +import { ENVIRONMENT_NAME } from "../app.constants"; export function configureNunjucks( app: express.Application, @@ -11,7 +13,7 @@ export function configureNunjucks( const nunjucksEnv: nunjucks.Environment = nunjucks.configure(viewsPath, { autoescape: true, express: app, - noCache: true, + noCache: getNodeEnv() !== ENVIRONMENT_NAME.PROD, }); nunjucksEnv.addFilter("translate", function (key: string, options?: any) {