fastify-static icon indicating copy to clipboard operation
fastify-static copied to clipboard

Using fastify-compression breaks Response time for static assets on browser

Open usopan opened this issue 8 years ago • 5 comments

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 image

PS Request is being made on localhost and if I remove compression it works properly but without compression ofcourse.

usopan avatar Apr 19 '18 09:04 usopan

Which version of fastify, fastify-static, fastify-compress are you using?

mcollina avatar Apr 19 '18 09:04 mcollina

Can you please upload a full example?

mcollina avatar Apr 19 '18 09:04 mcollina

"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.

usopan avatar Apr 19 '18 09:04 usopan

Fixed in fastify-compress 0.6.0.

mcollina avatar Apr 19 '18 14:04 mcollina

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.

github-actions[bot] avatar Nov 01 '26 03:11 github-actions[bot]