performance: i18n maxage (#4759)
parent
01c83917d1
commit
4c4c7b526d
|
@ -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);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue