nodejs http request compression (without express but with the possibility of renderize files with jade)

StackOverflow https://stackoverflow.com/questions/21460910

سؤال

How to send compressed gzipped file when requested from client ?

For example I have:

var zlib = require("zlib"),
    http = require("http");

http.createServer(function(req, res) {
    /*req.url is the url of the file requested
    how to compress and send the file here?
    consider that usually (facoltative) I can renderize the file also with Jade.renderFile()
    so the best solution is to compress the output before sending to client */
}).listen(80);

and how to cache for avoid multiple gzip requests ?

هل كانت مفيدة؟

المحلول

resolved compressing html data returned by jade.renderFile() callback

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top