WEBVTT

00:00.200 --> 00:00.920
Hey, everyone.

00:00.920 --> 00:02.450
And welcome back.

00:02.450 --> 00:09.650
Now, in the earlier lecture, we basically used our browser to look into how the cache control header

00:09.650 --> 00:10.700
really works.

00:10.730 --> 00:20.060
Now, in today's lecture we will be configuring our own Nginx Docker instance to include various kind

00:20.060 --> 00:23.690
of cache control headers and we'll start with no store for now.

00:24.140 --> 00:25.640
So let's go ahead.

00:25.640 --> 00:29.040
I have my docker nginx container up and running.

00:29.060 --> 00:34.640
Now before we start, what we'll do is we'll download these two images.

00:36.170 --> 00:37.970
So let's do one thing.

00:37.970 --> 00:41.240
So I have one image called as MC dot jpeg.

00:41.630 --> 00:49.010
I'll copy the URL and I'll do a wget perfect.

00:49.010 --> 00:53.390
And similarly I'll copy the node store dot PNG.

00:55.970 --> 00:56.510
Perfect.

00:56.510 --> 00:59.120
So I have done wget for both of them.

00:59.120 --> 01:04.320
So you'll see both of these files are part of my docker.

01:05.550 --> 01:15.090
Now just to avoid confusion, what I'll do, I'll rename the file called as Docker seed dot jpg and

01:15.240 --> 01:18.660
I'll rename node store to Docker.

01:19.110 --> 01:22.410
No store dot jpg dot PNG.

01:23.610 --> 01:24.420
Perfect.

01:24.450 --> 01:27.450
Now we have both the files up and running.

01:27.450 --> 01:37.680
Now just to verify if everything is working, I'll do a curl hyphen i on http example.com

01:39.810 --> 01:41.760
docker dot jpg.

01:43.380 --> 01:49.320
You got a proper response and you will see there is no cache control header over here.

01:49.830 --> 01:58.230
Similarly, I'll do a docker node store dot PNG and again you'll see there is no cache control header

01:58.230 --> 01:58.830
over here.

01:58.830 --> 02:06.090
So whenever you open this file in the browser, the browser will store the file in the cache depending

02:06.090 --> 02:08.310
upon its own configuration.

02:08.310 --> 02:14.970
So what we will be doing is for this specific file or for this extension, PNG extension, we will be

02:14.970 --> 02:20.820
adding a new header called as cache control header, which signifies a no store directive.

02:21.000 --> 02:23.580
So let's look into how we can do that.

02:23.610 --> 02:26.280
So I'll go to our Nginx configuration.

02:28.560 --> 02:36.390
And if you look into labs dot conf, we don't really have an explicit headers which are mentioned,

02:36.570 --> 02:39.630
so we'll go ahead and create our own header.

02:40.500 --> 02:51.600
So I'll say location for all the locations which ends with PNG or for all the extensions which end with

02:51.630 --> 02:52.080
PNG.

02:52.740 --> 02:57.110
I'll say root is for websites.

02:58.170 --> 03:07.810
So this specific aspect I copied from here and there is one important configuration which is add header.

03:07.830 --> 03:15.090
So add header will specify adding of new header in the response.

03:15.270 --> 03:17.310
Now I'll say cache control.

03:21.110 --> 03:24.890
And let me.

03:28.050 --> 03:39.270
This actually is a problem with Nano somehow in Docker when you use the CMD.

03:39.660 --> 03:42.870
So cache control will be no stored.

03:43.830 --> 03:44.370
Okay.

03:44.910 --> 03:47.520
And I'll close the file.

03:49.410 --> 03:51.300
Let me do a nginx hyphen t.

03:51.540 --> 03:54.750
Everything seems to be successful and I'll do a service.

03:54.750 --> 03:55.710
Enginex restart.

03:56.040 --> 03:56.790
Perfect.

03:56.790 --> 03:59.560
So things seems to be working correctly now.

03:59.580 --> 04:00.690
Let's do one thing.

04:00.690 --> 04:02.940
Let's do a docker node store.

04:03.090 --> 04:11.580
And now what you see is you see there is a new header called as cache control and the value is no stored.

04:11.680 --> 04:14.310
Now we did one mistake.

04:14.340 --> 04:16.620
There seems to be two colon over here.

04:16.770 --> 04:18.840
This is not expected.

04:20.640 --> 04:21.750
So.

04:26.350 --> 04:30.370
So this is something which we added by mistake.

04:30.700 --> 04:33.460
I'll just restart Nginx.

04:36.720 --> 04:38.790
And let's try this out.

04:38.820 --> 04:39.990
And perfect.

04:39.990 --> 04:45.810
So now we have a perfect cache control header for Docker node store dot PNG.

04:45.960 --> 04:55.200
So as expected, browser should follow this header and it should not store the docker node dot PNG.

04:55.470 --> 05:05.250
However, when you talk about the docker dot jpg it as it does not have a cache control header browser

05:05.250 --> 05:08.880
will go ahead and store this file in its cache.

05:09.270 --> 05:11.530
So let's try this out.

05:11.550 --> 05:24.630
I'll copy this URL and let's close the earlier terminal and I'll paste the URL Docker seed dot jpg.

05:24.660 --> 05:25.020
Perfect.

05:25.020 --> 05:26.970
So now we have the image.

05:27.090 --> 05:39.610
Correspondingly, we'll copy the second URL, which is Docker node store and I'll paste it again in

05:39.610 --> 05:41.590
my chrome.

05:41.620 --> 05:42.220
Perfect.

05:42.220 --> 05:45.280
So now we have both the images which you will see.

05:45.310 --> 05:54.970
However, if you do a about cache, since these are the key, I'll just copy the URL so you have the

05:55.000 --> 05:56.140
URL over your docker.

05:56.530 --> 05:56.920
JPG.

05:56.950 --> 05:59.890
You see the Chrome has cached this entry.

05:59.920 --> 06:07.090
However, now if I do you see I do not really get any result over here.

06:07.330 --> 06:12.940
And this is what the no store header basically is all about.

06:13.960 --> 06:24.700
So last thing just to reconfirm, the ad header is basically used to add a header in the response.

06:24.730 --> 06:28.630
Now it will not add header for all the response.

06:28.630 --> 06:34.390
It will only add header for the response with the extension dot PNG.

06:34.390 --> 06:44.680
So you have a location which is specific for extension dot PNG files and specific for any file which

06:44.680 --> 06:45.820
ends with PNG.

06:46.150 --> 06:52.510
The ad header directive will be included, so go ahead and try this out.

06:52.510 --> 06:55.750
This is quite interesting and fun to do.

06:55.870 --> 07:02.080
I hope this has been informative for you and I look forward to see you in the next lecture with the

07:02.080 --> 07:04.930
next cache control directives.
