nodejs http请求压缩(没有快速但有可能用jde渲染文件)

时间:2014-01-30 15:42:18

标签: javascript node.js http gzip zlib

如何从客户端请求时发送压缩的gzip压缩文件?

例如我有:

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);

以及如何缓存以避免多个gzip请求?

1 个答案:

答案 0 :(得分:0)

解析了压缩jade.renderFile()回调

返回的html数据