diff --git a/conf/default.yaml b/conf/default.yaml index b3097a22b..49c6f43f0 100644 --- a/conf/default.yaml +++ b/conf/default.yaml @@ -19,6 +19,7 @@ web: # sort_packages: asc # convert your UI to the dark side # darkMode: true + # html_cache: true # logo: http://somedomain/somelogo.png # favicon: http://somedomain/favicon.ico | /path/favicon.ico # rateLimit: diff --git a/conf/docker.yaml b/conf/docker.yaml index 0ebf5e570..346ef041b 100644 --- a/conf/docker.yaml +++ b/conf/docker.yaml @@ -24,6 +24,7 @@ web: # by default packages are ordercer ascendant (asc|desc) # sort_packages: asc # darkMode: true + # html_cache: true # logo: http://somedomain/somelogo.png # favicon: http://somedomain/favicon.ico | /path/favicon.ico # rateLimit: diff --git a/src/api/web/html/renderHTML.ts b/src/api/web/html/renderHTML.ts index 067742686..e65d51f87 100644 --- a/src/api/web/html/renderHTML.ts +++ b/src/api/web/html/renderHTML.ts @@ -47,6 +47,7 @@ export default function renderHTML(config, manifest, manifestFiles, req, res) { const base = getPublicUrl(config?.url_prefix, req); const basename = new URL(base).pathname; const language = config?.i18n?.web ?? DEFAULT_LANGUAGE; + const needHtmlCache = [undefined, null].includes(config?.web?.html_cache) ? true : config.web.html_cache; const darkMode = config?.web?.darkMode ?? false; const title = config?.web?.title ?? WEB_TITLE; const scope = config?.web?.scope ?? ''; @@ -83,7 +84,6 @@ export default function renderHTML(config, manifest, manifestFiles, req, res) { try { webPage = cache.get('template'); - if (!webPage) { debug('web options %o', options); debug('web manifestFiles %o', manifestFiles); @@ -98,8 +98,10 @@ export default function renderHTML(config, manifest, manifestFiles, req, res) { manifest ); debug('template :: %o', webPage); - cache.set('template', webPage); - debug('set template cache'); + if (needHtmlCache) { + cache.set('template', webPage); + debug('set template cache'); + } } else { debug('reuse template cache'); }