Http compression is one of the very important features of the Http protocol.
The reason for this is because not only it saves your bandwidth, but also the transverse fields becomes
very, very fast.
So essentially, if a website is using compression, then the website can actually load much more faster
than the one which does not use compression.
So let's understand on how compression can help as far as the Http protocol is concerned.
So we have scenario one where there is a website which is running without compression.
So let's assume that slash index dot HTML.
So I'll say index dot HTML is of size 3000 bytes.
I'll say 3000 bytes.
Now, in order to send this amount of data through the TCP protocol, we already know that if the size
of TCP is, say, 1500 bytes, then in order to send the index dot HTML, we'll need three TCP packets.
So this is packet one.
Let's say this is packet two and this is TCP packet three.
So all of these packets are sent to the client from the server and the third packet as well.
And before that the client will send the get request.
Now the problem with this is that for each client it is actually sending three TCP packets so that it
can send 3000 bytes of data associated.
Now, this is not a big problem.
If the amount of clients that are connecting to the servers are less.
So if we assume that the amount of client are 100, then for 100 client there will be three TCP packets
for each individual.
So amount of packet will be 300.
So I will say 300 TCP packets.
Now, this is also not a big problem.
So if we consider corporate websites where you actually have millions of users who are connecting to
your particular server, so during that time, the amount of TCP packets which will be sent over the
network will be tremendous.
So it causes two big problems.
The first is the bandwidth and the second is the speed.
So as it is sending three TCP packets, it will take some amount of time to load the website.
Now, this is considered, as you can also say, as website is running slow.
Maybe so.
This is one of the reasons why even Google sometimes penalizes the website because it loads very slow.
So this is the basics of scenario without compression.
So let's take second scenario where you are actually using the compression.
So let's go down and this is the scenario with compression.
We'll have a say.
So index dot HTML.
I'll say index dot HTML is of 3000 bytes.
M2 is 1500, so it will take total of three packets to send the data.
So what we basically do is this time we decide to use compression.
So we compress index dot HTML and the 3000 bytes of data actually gets let's assume it goes to around
2000 bytes.
Compression can actually reduce the size by 70% also.
So it can actually go down much more further.
But for our example, let's consider 2000 bytes.
So in order to transmit the 2000 bytes, we already know it will take two TCP packets with the M2 of
1500 bytes.
So now whenever a get request is made from the server to client, so this is get the server actually
have to only send two TCP packets to transmit the data.
So this is two TCP packets and the data is then loaded on the browser.
So now there is certain amount of compression.
Now as we have already discussed, if it is, if the site is getting around 100 users, then the bandwidth
saving won't be much.
But this will affect a lot.
If a website is getting millions of users, then the amount of bandwidth that is saved is actually a
lot.
So if we say millions of users.
So if you compare scenario one and scenario two, so in scenario two, actually one packet is getting
saved.
So that means for million users you have million packet which got saved because now one packet is not
sent because of the compression ability.
The second important benefit is the speed.
Or you can also say site speed.
The reason for this is because as there are only two packets sent, the amount of time it takes to send
two packets is much more lesser.
That's the reason why your website will actually load much more faster.
And this is why compression is used in almost all the major websites.
So there are lot of ways in which you can compress the data when you use the Http protocol.
But in this video, I just wanted to give you an overview on how exactly a compression can help, not
only as far as the transfer speed is concerned, but also as far as the bandwidth is concerned.
So I hope you got the basic overview on why compression is necessary as far as the Http protocol is
concerned.
So I hope this video has been informative for you and I'd like to thank you for viewing.