Next.js: Gzip compression for static folder

Created on 3 Feb 2017  路  9Comments  路  Source: vercel/next.js

I'm using next 2 beta 20 and I have a css file in static folder. But looks like next.js doesn't gzip it by default. I know that I can write a custom server (or even use something like nginx for better performance) to server the static folder. But don't you think this should be the default behaviour?

By the way, thank you for making next.js . It's awesome. Make developement just like the old PHP day

Most helpful comment

We have been slowly rolling out gzip compression for all now deployments, and it should shortly be globally available for all now deployments.

All 9 comments

@arunoda is there a reason for not gzipping the static folder files by default?

@impronunciable we didn't had any big reason for that.
I was not going after that because, for a production build we should host those files on a CDN.

On the other side, if there are a lot of files, it'll affect our to build time too.
So, we should not do this by default. But doing it with an option it totally fine.

I'm -1 on this. I'm actually considering removing compression altogether from Next. What if we just let load balancers handle that?

For example, if we make sure that we send the right caching headers, combined with a somewhat-smart proxy / load balancer, compression is super easy and reduces the footprint of Next!

I'm familiar with setting up the load balancer and other DevOps stuff. But the only reason I asked this questions is because I'm using Now.sh (free account) and it doesn't gzip the file.

@thangngoc89 you could use cloudflare or max-cdn on top of now. Now.sh certainly not a CDN but a hosting service.

May be @rauchg @jamo could tell more on future plans related to this.

After thinking about this for a while, I think it's best the next.js doesn't handle gzip compression. Node.js is single core after all and CPU heavy task is not suitable for node application. I'll put a CDN in front of my app when it does to production. Thank you again.

We have been slowly rolling out gzip compression for all now deployments, and it should shortly be globally available for all now deployments.

Was this page helpful?
0 / 5 - 0 ratings