mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-11-08 23:25:51 +01:00
feat(web): add a config item to web,let the developer can select whether enable the html cache (#3110)
* Add a config item to web,let the developer can select whether enable the html cache * Add a config item to web,let the developer can select whether enable the html cache * chore: move check close to other configuration * chore: update configuration files to suggest new option on web * chore: format fix Co-authored-by: fengdi <fengdi@bbktel.com> Co-authored-by: Juan Picado <juanpicado19@gmail.com>
This commit is contained in:
parent
b963f7db2a
commit
b30ba81b86
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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');
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user