|
@@ -2,11 +2,16 @@ const Express = require('express'); |
|
@@ -2,11 +2,16 @@ const Express = require('express'); |
2
|
let router = Express.Router(); // eslint-disable-line
|
2
|
let router = Express.Router(); // eslint-disable-line
|
3
|
const rp = require('request-promise');
|
3
|
const rp = require('request-promise');
|
4
|
const env = global.env;
|
4
|
const env = global.env;
|
|
|
5
|
+const pageCache = {};
|
5
|
|
6
|
|
6
|
let mainProxy = (req, res) => {
|
7
|
let mainProxy = (req, res) => {
|
7
|
res.header('x-version', env.version);
|
8
|
res.header('x-version', env.version);
|
8
|
res.header('cache-control', 'no-store');
|
9
|
res.header('cache-control', 'no-store');
|
9
|
- rp.get(`http://cdn.yoho.cn/yoho-shop-manage/${env.version}/index.html`).then(body => {
|
10
|
+ if (pageCache[env.version]) {
|
|
|
11
|
+ return res.send(pageCache[env.version]);
|
|
|
12
|
+ }
|
|
|
13
|
+ return rp.get(`http://cdn.yoho.cn/yoho-shop-manage/${env.version}/index.html`).then(body => {
|
|
|
14
|
+ pageCache[env.version] = body;
|
10
|
res.send(body);
|
15
|
res.send(body);
|
11
|
});
|
16
|
});
|
12
|
};
|
17
|
};
|