Nuxt.js: Performance. Adding express-static-gzip for precompressed files

Created on 9 Apr 2017  路  4Comments  路  Source: nuxt/nuxt.js

Hello and thank you for nuxt!

You recently added compression for dynamic creation of gzip files for every request that nodejs server receives. Nodejs is already not the most effecient web server and making it to dynamically build gzip files is questionable to enable.

This question is available on Nuxt.js community (#c459)
question

Most helpful comment

Hi @OlzhasAlexandrov

Thank you for your suggestion but this might be too complicated for most users.

I believe this could be a nuxt plugin in the future like nuxt-static-gzip which will run the command find . -type f ! -name "*.gz" | while read -r x; do gzip -c9 "$x" > "$x.gz"; done or something similar and then add the express-static-gzip middleware to nuxt.render.

I add this issue in the Project to keep this idea and close this issue.

All 4 comments

I had to edit the initial comment, because I previously suggested incompatible middleware. It was for connect(not express).

How about adding express-static-gzip to nuxt?

Developers would be able to gzip all files using a command like this:
find . -type f ! -name "*.gz" | while read -r x; do gzip -c9 "$x" > "$x.gz"; done
and then nodejs server won't dynamically build a gzip file every time, but use a static file instead.
We could even possibly add brotli precompressed files for supported browsers, allowing further decrease in size.

Just found out that I personally didn't need this feature, since there is already publicPath which allows to set a folder and serve gzip static files through a reverse-proxy server, like nginx with gzip_static on;

On the other hand, if you want to support situations, when nodejs directly serves files, then it might be a good idea to add precompressed file support

Hi @OlzhasAlexandrov

Thank you for your suggestion but this might be too complicated for most users.

I believe this could be a nuxt plugin in the future like nuxt-static-gzip which will run the command find . -type f ! -name "*.gz" | while read -r x; do gzip -c9 "$x" > "$x.gz"; done or something similar and then add the express-static-gzip middleware to nuxt.render.

I add this issue in the Project to keep this idea and close this issue.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vadimsg picture vadimsg  路  3Comments

msudgh picture msudgh  路  3Comments

nassimbenkirane picture nassimbenkirane  路  3Comments

lazycrazy picture lazycrazy  路  3Comments

vadimsg picture vadimsg  路  3Comments