最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - What is bundle.js.gz file in angular 2? - Stack Overflow

programmeradmin1浏览0评论

I am using ng-cli for my application. when i run ng build --prod, i got two files main.budle.js & main.bundle.js.gz. what is the second one & what is the benefit of it?

I am using ng-cli for my application. when i run ng build --prod, i got two files main.budle.js & main.bundle.js.gz. what is the second one & what is the benefit of it?

Share Improve this question asked Oct 1, 2016 at 5:50 ManishManish 2,19018 silver badges18 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 8

HTTP transfer between server and client almost always uses pression. In most cases this is gzip.

So what matters for transfer times is not the size of your bundle.js but the size of bundle.js.gz as content is practically always sent in its gzip pressed form.

When bundle.js is requested, the server gzips it on the fly and puts it on the wire. So gzip is run on every request, which is inefficient for static content.

Also gzip's performance drops significantly with the level of pression (check out this article). Using the highest pression level possible isn't efficient if at all possible on-the-fly. A properly configured webserver would send bundle.js.gz when a gzipped version of bundle.js is requested, so you could use the highest pression level gzip can provide.

In my opinion, the performance bonus of this is negligible unless your server mainly provides static content that can be pressed ahead-of-time. For a small application, with static content and API being served from the same machine, there should be practically no impact.

Gzipped folders are meant for server. Your server must have such configuration for that. Write it in your server conf files so that they could send gzipped folders.

发布评论

评论列表(0)

  1. 暂无评论