Commit bc1fca1e authored by Elvis Pranskevichus's avatar Elvis Pranskevichus

servers/nodejs_http: Cache responses

parent 67be2bb0
...@@ -2,6 +2,7 @@ var http = require('http'); ...@@ -2,6 +2,7 @@ var http = require('http');
const PORT = 25000; const PORT = 25000;
var responses = {};
function handle(request, response) { function handle(request, response) {
...@@ -11,10 +12,15 @@ function handle(request, response) { ...@@ -11,10 +12,15 @@ function handle(request, response) {
} else { } else {
msize = parseInt(msize); msize = parseInt(msize);
} }
response.end(Array(msize).join("X")); if (!responses[msize]) {
responses[msize] = Array(msize).join("X");
}
response.end(responses[msize]);
} }
var server = http.createServer(handle); var server = http.createServer(handle);
server.listen(PORT, function() {}); server.listen(PORT, function() {
console.log('Serving on ::' + PORT.toString());
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment