I'm trying to static serve brotli compressed files. I was able to compress files with this code:
// node.js
const compressStream = require("iltorb").compressStream;
const fs = require("fs");
const wrr = fs.createWriteStream("index-b.html");
fs.createReadStream("index.html")
.pipe(compressStream())
.pipe(wrr);
So now the index-b.html
file is compressed. But how can I see this on browser?
When I go to that page, this is what I'm seeing:
I thought the browser will understand this is a brotli encoded file. But it didn't. When I looked at the response headers,
HTTP/1.1 200 OK
server: ecstatic-3.3.1
cache-control: max-age=3600
last-modified: Sat, 06 Apr 2019 17:27:32 GMT
etag: W/"281474976993459-334-2019-04-06T17:27:32.047Z"
content-length: 334
content-type: text/html; charset=UTF-8
Date: Sat, 06 Apr 2019 17:36:49 GMT
Connection: keep-alive
there was no encoding set. How can I address this?