Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I enable Gzip in Fastify-static #45

Closed
avilang opened this issue Mar 30, 2018 · 5 comments
Closed

How can I enable Gzip in Fastify-static #45

avilang opened this issue Mar 30, 2018 · 5 comments

Comments

@avilang
Copy link

avilang commented Mar 30, 2018

No description provided.

@delvedor
Copy link
Member

Use fastify-compress.

@usopan
Copy link

usopan commented Apr 19, 2018

I am using the same but on browser request end is not being set properly. Request response time on browser shows 5s but in trace logs of fastify it show request completed within few ms.

PS I am not using any proxy to run this test. and if I remove compression response time is as expected.

@mcollina
Copy link
Member

Can you upload an example to reproduce? Thanks.

@usopan
Copy link

usopan commented Apr 19, 2018

#52

@PierBover
Copy link

If anyone stumbles upon this as I did... you need to register the fastify-compress global hook before registering fastify-static.

fastify.register(require('fastify-compress'));

fastify.register(require('fastify-static'), {
	root: path.join(__dirname, 'public'),
	prefix: '/public/'
});

Otherwise responses of static files won't be compressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants