WEBVTT

00:00.230 --> 00:03.980
Hey, everyone, and welcome back to the Knowledge Portal Video series.

00:04.010 --> 00:11.260
Now, continuing our journey with the get method will be speaking about conditional get in today's lecture.

00:11.270 --> 00:14.180
So let's go ahead and understand more about this.

00:15.930 --> 00:20.340
Now conditional get method is used to fetch information.

00:20.370 --> 00:23.190
However, with a specific condition.

00:23.340 --> 00:32.520
So in this example we have a get method which is get slash sample dot HTML for the http 1.1 protocol.

00:32.550 --> 00:40.710
Host is Dexter labs in and a condition which is specified over here is that if modified since.

00:40.710 --> 00:45.150
So this is the header and there is a date and time associated.

00:45.180 --> 00:56.040
So you have if modified since Saturday, 18th October 2017 at evening, 7:00 and 43 minutes and 31 seconds

00:56.040 --> 00:57.210
of GMT time.

00:57.750 --> 01:06.840
So what this basically says that get me this file only and only if it is modified after this specific

01:06.840 --> 01:07.410
time.

01:07.740 --> 01:11.880
If it is not modified that, then do not really need the file.

01:11.880 --> 01:15.940
I just need the file if it is modified or if it is updated.

01:16.600 --> 01:20.320
So this is the basic about conditional get.

01:20.350 --> 01:26.320
Let's get back to our labs and we'll understand this specific value.

01:27.010 --> 01:40.750
So when you do a curl on Dexter labs dot in slash sample dot HTML this time I'll do a hyphen I so that

01:40.750 --> 01:42.490
we can see the response headers.

01:44.010 --> 01:52.410
And within the response header there is a very important header called last modified and followed.

01:52.560 --> 02:02.820
The value associated with this header is Wednesday, 18th October 2017 at 5:00, 19 minutes and 43 seconds

02:02.820 --> 02:03.300
GMT.

02:03.540 --> 02:14.430
So this response header basically tells us on what was the last time this file sample dot HTML was modified.

02:14.640 --> 02:24.630
Now this is a very important header because if a browser is or if a user is trying to load this file

02:24.630 --> 02:30.150
again and again, and if the file is not modified, what a browser can do is browser can store this

02:30.150 --> 02:35.490
file in cache and it can only supply the newer version.

02:35.520 --> 02:38.610
If this last modified date has been updated.

02:38.610 --> 02:41.670
We'll be discussing this in the upcoming lectures.

02:42.030 --> 02:44.560
But for the time being, let's do one thing.

02:45.370 --> 02:54.700
Let's do a curl and I'll say Dexter dot P labs dot n slash sample dot HTML.

02:55.000 --> 02:59.110
So this time I'll get a response, which is of two lines.

02:59.440 --> 03:05.050
This is sample sample file and it is specifically designed for get request.

03:05.080 --> 03:11.740
Now we'll add an additional header with hyphen hyphen header.

03:13.600 --> 03:21.370
And this time I'll add a header if modified since.

03:25.030 --> 03:29.710
And we'll put a value which is present over here.

03:32.080 --> 03:35.770
I'll paste it and I'll press enter.

03:36.610 --> 03:40.810
Now here you will see you did not really get any response.

03:40.840 --> 03:47.920
Now, the reason why you did not get response is because the file is not modified after this specific

03:47.920 --> 03:56.230
time that we have mentioned over here, if the file gets modified after this date and time which is

03:56.230 --> 04:01.180
specified, then the response will be received.

04:01.210 --> 04:06.880
So let's try one thing instead of 519.

04:07.000 --> 04:11.950
I'll say 518 So just a minute back and I'll press enter.

04:11.950 --> 04:15.160
And now you'll see I got the response back.

04:15.340 --> 04:23.710
Now, the reason why I got response is because the file was modified after this specific time interval

04:23.710 --> 04:27.820
that we have been writing in our header file.

04:28.690 --> 04:36.340
So if you look into the headers, let's do one thing.

04:38.230 --> 04:45.910
I'll put hyphen I so in hyphen I you are getting the response because file was actually modified at

04:45.910 --> 04:46.990
519.

04:47.140 --> 04:55.630
Now if I do 519 back here again this time instead of 200.

04:55.630 --> 04:59.560
Okay, you will get 304 not modified.

04:59.590 --> 05:08.710
So the web server is saying to the client that the file has not been modified after this specific amount

05:08.710 --> 05:12.790
of time and thus the response is not received.

05:12.790 --> 05:21.610
The contents of this file is being not received, and this specific conditional plays a very important

05:21.610 --> 05:25.240
role during the caching process of browsers.

05:25.360 --> 05:29.750
So this is the basic about the conditional get.

05:29.770 --> 05:33.510
I hope you got what a condition basically means.

05:33.520 --> 05:37.690
So this specific condition is something that we are specifying.

05:37.690 --> 05:41.420
Like if this condition is met, then only send us the file.

05:41.440 --> 05:44.750
If condition is not met, do not send me the file.

05:44.770 --> 05:49.780
So this is what the high level overview of the conditional get really means.

05:49.810 --> 05:52.450
So this is it about this lecture.

05:52.630 --> 05:54.790
I hope this has been informative for you.

05:54.820 --> 06:00.490
Again, if you have any doubts suggestions, feel free to connect us at Twitter, Facebook or LinkedIn

06:00.490 --> 06:04.030
or mail us at instructors at the Rate Labs dot n.

06:04.060 --> 06:05.260
Thanks for watching.
