 <p>It looks as if you want to use Express and the <code>express.compress</code> middleware. That will figure out if a browser supports gzip and/or deflate, so you don't have to.</p> <p>A simple setup could look like this: </p> <pre><code>var express = require('express'); var app = express(); app.use(express.compress()); app.get('/', function(req, res) { res.send({ app_id: 'A3000990' }); }); app.listen(3000); </code></pre> <p>If your data is a JSON-string, you have to set the correct content-type header yourself:</p> <pre><code>res.setHeader('Content-Type', 'application/json'); res.send(data); </code></pre>