Postprocess gzip for performance
See original GitHub issue- Laravel Mix Version: 0.10.0
- Node Version: 6.10.2
- NPM Version: 3.10.10
- OS: Ubuntu
Description:
Utilizing the gzip_static module in nginx can reduce the load on the webserver. Instead of compressing script, css and other compressibles on-the-fly for each request, these can be provided pre-compressed and nginx will just use those.
It may be possible to achieve the same behaviour in apache, but I don’t use it so I am not aware of it.
It is probably not necessary to do this in development, so it could be integrated with production flag and a optional setting in the mix config file to enable it.
I understand that mix is used on non-linux platforms so an equivalent processing step built in would be nicer since mix already has access to all the files which it has processed.
Of course, these files would have to be deleted when running npm run dev
or similar commands so that will also need to be handled
Steps To Reproduce:
On linux, a single liner can achieve this behaviour as below on existing files:
find public/ -name '*.js' -or -name '*.css' -or -name '*.svg' -or -name '*.eot' -or -name '*.ttf' -or -name '*.woff' -or -name '*.woff2' | xargs gzip -6 -k
Issue Analytics
- State:
- Created 6 years ago
- Comments:8
Top GitHub Comments
Following up both this issue and #619 this sounds indeed like a good feature and the justification behind them is valid. This would definitively be useful as part of Laravel Mix.
Reason is described in #619 nginx’s gzip_static relies on pre-compressed version of file: ex. if app.js.gz exists, it serves it instead of app.js (doesn’t perform compression itself) and saves CPU and TTFB dramatically. But someone should create that .gz file. Bundler is ideal candidate for that.