diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-06-02 17:06:04 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-06-02 17:06:04 +0200 |
| commit | 75ff985533fdbd7ea7d8ae564ce2525fb71cca1d (patch) | |
| tree | 73737ba03c2b27b6414812e566901216c1c00442 /app/server/proxy.js | |
| parent | ae00ab973a95c656930d6d6263b5bd744a3b0cee (diff) | |
cache proxy too :o)
Diffstat (limited to 'app/server/proxy.js')
| -rw-r--r-- | app/server/proxy.js | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/app/server/proxy.js b/app/server/proxy.js index b6ca14c..2dcc1d7 100644 --- a/app/server/proxy.js +++ b/app/server/proxy.js @@ -33,11 +33,11 @@ function serve(req, res) { console.log(req.method, req.url) - // if (USE_CACHE && req.method == 'GET' && req.url in cache) { - // res.writeHeader(200, { 'Content-type': 'application/json' }) - // res.end(cache[req.url]) - // return - // } + if (process.env.PROXY_CACHE && req.method == 'GET' && req.url in cache) { + res.writeHeader(200, { 'Content-type': 'application/json' }) + res.end(cache[req.url]) + return + } // console.log(req.headers) @@ -61,12 +61,12 @@ function serve(req, res) { res.writeHeader(server_res.statusCode, server_res.headers) server_res.pipe(res) - // if (! options.headers['x-yoox-cart-token']) { - // cache[req.url] = '' - // server_res.on('data', function(s){ - // cache[req.url] += s.toString() - // }) - // } + if (process.env.PROXY_CACHE) { + cache[req.url] = '' + server_res.on('data', function(s){ + cache[req.url] += s.toString() + }) + } if (DEBUG) { server_res.on('data', s => console.log(s.toString())) |
