Using fastify-compression breaks Response time for static assets on browser
Config
fastify.register(require('fastify-compress'), { threshold: 0 });
fastify.register(fastifyStatic, __PROD__ ? {
root: path.resolve(path.join(__dirname, '/../', 'public')),
prefix: '/public/',
setHeaders: function (res, path, stat) {
res.setHeader('Content-Encoding', 'gzip')
// console.log(stat)
}
}
tracelog on server
{"level":30,"time":1524127887660,"msg":"incoming request","pid":11241,"hostname":"utkarsh-Lenovo-ideapad-300-15ISK","reqId":9,"req":{"id":9,"method":"GET","url":"/public/assets/15_e8d859185f2e2b063a5c.js","remoteAddress":"127.0.0.1","remotePort":37776},"v":1}
{"level":30,"time":1524127887668,"msg":"request completed","pid":11241,"hostname":"utkarsh-Lenovo-ideapad-300-15ISK","reqId":9,"res":{"statusCode":200},"responseTime":7.410842999815941,"v":1}
Browser

PS Request is being made on localhost and if I remove compression it works properly but without compression ofcourse.
Which version of fastify, fastify-static, fastify-compress are you using?
Can you please upload a full example?
"fastify": "^1.2.1", "fastify-compress": "^0.5.1", "fastify-static": "^0.10.1", Also what do you mean by full example? I am currently working on a private repo So I can only share specific code. Please let me know what all you need to see.
Fixed in fastify-compress 0.6.0.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.