Authored by 陈峰

bug:性能问题,不要每次都从cdn获取html文件

... ... @@ -57,8 +57,12 @@ const middleware = require('./middleware');
const controllers = require('./controllers');
app.use('/crm/common/ok.jsp', (req, res) => {
res.status(204).end();
res.status(200).end();
});
app.head('*', (req, res) => {
res.status(200).end();
});
try {
app.use(middleware.main);
... ...
... ... @@ -2,11 +2,16 @@ const Express = require('express');
let router = Express.Router(); // eslint-disable-line
const rp = require('request-promise');
const env = global.env;
const pageCache = {};
let mainProxy = (req, res) => {
res.header('x-version', env.version);
res.header('cache-control', 'no-store');
rp.get(`http://cdn.yoho.cn/yoho-shop-manage/${env.version}/index.html`).then(body => {
if (pageCache[env.version]) {
return res.send(pageCache[env.version]);
}
return rp.get(`http://cdn.yoho.cn/yoho-shop-manage/${env.version}/index.html`).then(body => {
pageCache[env.version] = body;
res.send(body);
});
};
... ...