WEBVTT

00:00.410 --> 00:09.020
In the last lecture we were talking about the Http headers, which were except encoding and content

00:09.020 --> 00:09.860
encoding.

00:09.980 --> 00:17.720
So in this video we'll actually start with Nginx to see on how we can configure our Nginx server to

00:17.720 --> 00:20.660
support compression as well as decompression.

00:21.800 --> 00:28.130
So let's go to the Nginx directory and let's open nginx.conf.

00:29.960 --> 00:35.570
So if we go below there is a directive called as GZip on.

00:35.570 --> 00:43.130
So that means that the Nginx will support GZip based compression utility.

00:43.850 --> 00:51.500
Now just having GZip on will not actually start to compress your data.

00:52.130 --> 00:54.990
You have to have more directives.

00:55.010 --> 01:01.970
So let's start with one which is GZip, underscore types.

01:03.240 --> 01:12.690
I'll say text plain, maybe text CSS, say text, maybe XML.

01:13.860 --> 01:15.690
Text JavaScript.

01:17.690 --> 01:18.920
And so on.

01:20.060 --> 01:29.640
So it is necessary to specify on what type or what mime type of data that we have to compress.

01:29.660 --> 01:33.180
So all of these are the mime types.

01:33.200 --> 01:44.480
So once the server sees the accept encoding header, which is GZip from the client side, and if the

01:44.510 --> 01:51.950
get request has either one of these particular type, then the server will actually compress the data

01:51.950 --> 01:52.640
in send.

01:53.240 --> 02:01.370
Now generally the reason why we specify this is because we don't want to compress data such as image

02:01.370 --> 02:06.500
file or video file because there won't be much of compression that can be applied on that.

02:06.710 --> 02:16.070
So compression can be mostly applied into text based data, which can be CSS, XML, JavaScript, HTML

02:16.070 --> 02:17.310
or other things.

02:20.130 --> 02:33.360
So one more important directive is the gzip underscore disable, which has to be MSI.

02:35.640 --> 02:36.870
Let's see.

02:37.140 --> 02:38.640
One, two, six.

02:41.350 --> 02:42.320
A forward.

02:48.410 --> 02:59.020
So the reason why we have included this is because the Microsoft Internet Explorer from version 1 to

02:59.020 --> 03:02.030
6 actually does not work well with GZip properly.

03:02.030 --> 03:03.310
It does not support it.

03:03.320 --> 03:15.620
So this is the reason why we have to implicitly specify that disable the GZip for anything or any Microsoft

03:15.620 --> 03:19.310
Internet Explorer browser from version 1 to 6.

03:19.460 --> 03:24.920
So this is one of the important parameters that you have to mention.

03:25.280 --> 03:31.940
So let's save the file and let's do Nginx and everything is successful.

03:32.360 --> 03:34.160
Let's reload the Nginx.

03:38.320 --> 03:41.680
Okay, so the engine seems to be working properly.

03:41.980 --> 03:49.870
So let's go to temp and I've created a directory called as test and we'll use the curl utility and see

03:49.870 --> 03:52.420
how the compression has helped.

03:52.900 --> 04:03.310
So I'll say curl, let's say curl followed by the http example.com.

04:05.460 --> 04:09.000
Followed by the sshd underscore config dot txt.

04:11.120 --> 04:14.780
And save it as a c1 dot txt.

04:18.660 --> 04:20.610
Okay if I do?

04:22.410 --> 04:23.640
This is the size.

04:27.420 --> 04:32.100
Now let's run the same command with Hyphen H.

04:32.130 --> 04:33.660
I'll explain what this is.

04:34.680 --> 04:39.450
Let's accept encoding which would be GZip.

04:42.120 --> 04:46.530
And let's save this as c two dot txt.

04:47.520 --> 04:49.410
Let's do ls again.

04:49.410 --> 04:52.560
And now you see the difference between two files.

04:53.460 --> 04:58.960
So let's see what we have done through both the curl commands.

04:58.980 --> 05:04.230
So this was one of the first command and this was the second command.

05:05.790 --> 05:06.330
Okay.

05:06.330 --> 05:15.840
So in the first command we are trying to curl for sshd underscore config dot txt and the output is stored

05:15.840 --> 05:17.580
in c one dot txt file.

05:18.690 --> 05:26.100
However, for this particular request there is no except hyphen encoding header.

05:26.400 --> 05:29.910
So the server will not compress the data.

05:31.560 --> 05:40.590
However, for the second request we are explicitly specifying that the curl will support GZip based

05:40.590 --> 05:41.560
compression.

05:41.650 --> 05:48.620
So now server will compress the data with GZip and will send it to the curl utility.

05:48.640 --> 05:51.610
And we are storing it as c two dot txt.

05:52.780 --> 06:01.660
Now if we look into the size between c one and c two, c two, you will see the c two is much more less

06:01.660 --> 06:03.620
than that of c one dot txt.

06:03.640 --> 06:12.520
So from this you can determine that the compression has worked, provided the hyphen encoding is sent

06:12.520 --> 06:14.030
from the curl utility.

06:14.050 --> 06:19.240
So by default curl does not send it and you have to explicitly mention that.

06:21.420 --> 06:27.150
Now, one more important thing that you can mention.

06:29.720 --> 06:32.810
In the enginex configuration file is the.

06:36.170 --> 06:37.520
GZip compression level.

06:42.490 --> 06:43.180
Let's say nine.

06:43.390 --> 06:48.180
So GZip has compression level which starts from 1 to 9.

06:48.190 --> 06:52.870
So one is the fastest, but the compression level is very less.

06:53.560 --> 07:01.120
In nine, the compression ratio is great, but it takes a lot of computational power to compress that

07:01.120 --> 07:02.410
much amount of data.

07:03.370 --> 07:08.160
So ideally in server you should select between 1 to 9.

07:08.170 --> 07:12.160
So a lot of people select six, which is ideal to them.

07:13.120 --> 07:20.410
Many people select nine, provided you have enough amount of computational resources to compress that

07:20.410 --> 07:21.730
much amount of data.

07:22.600 --> 07:25.630
So this is it about the.

07:27.560 --> 07:32.240
Compression and decompression as far as the engine is concerned.

07:32.330 --> 07:36.500
So I hope this has been useful for you, and I'd like to thank you for viewing.
