performance: i18n maxage (#4759)

pull/4770/head
John McLear 2021-02-13 07:35:25 +00:00 committed by GitHub
parent 01c83917d1
commit 4c4c7b526d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 0 deletions

View File

@ -109,6 +109,7 @@ exports.expressCreateServer = (n, args, cb) => {
// works with /locale/en and /locale/en.json requests
const locale = req.params.locale.split('.')[0];
if (exports.availableLangs.hasOwnProperty(locale)) {
res.setHeader('Cache-Control', `public, max-age=${settings.maxAge}`);
res.setHeader('Content-Type', 'application/json; charset=utf-8');
res.send(`{"${locale}":${JSON.stringify(locales[locale])}}`);
} else {
@ -117,6 +118,7 @@ exports.expressCreateServer = (n, args, cb) => {
});
args.app.get('/locales.json', (req, res) => {
res.setHeader('Cache-Control', `public, max-age=${settings.maxAge}`);
res.setHeader('Content-Type', 'application/json; charset=utf-8');
res.send(localeIndex);
});