summaryrefslogtreecommitdiff
path: root/app/server
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2018-06-02 17:06:04 +0200
committerJules Laplace <julescarbon@gmail.com>2018-06-02 17:06:04 +0200
commit75ff985533fdbd7ea7d8ae564ce2525fb71cca1d (patch)
tree73737ba03c2b27b6414812e566901216c1c00442 /app/server
parentae00ab973a95c656930d6d6263b5bd744a3b0cee (diff)
cache proxy too :o)
Diffstat (limited to 'app/server')
-rw-r--r--app/server/proxy.js22
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()))