The HTTP If-Unmodified-Since header is a request-type header and makes the request conditional on having a last-modified timestamp. The server will perform the requested operation only if the requested source has not been modified after a specified date. In case, the requested source has been modified then sever will not perform the requested operation and respond with a 412 error (Precondition Failed).
Let us consider a scenario, a patient goes to a medical laboratory to get his BMI test. The lab attendant records his height and weight and tells him to collect the reports within 2 days. Due to some reasons, the patient could not collect the reports and goes to the laboratory after a month. But the lab attendant doesn’t give him the reports and informs him that the tests will be valid only if his weight is still unchanged(or unmodified), otherwise, the result has become inconsistent. This is how our If-Unmodified-Since HTTP header works.
If-Unmodified-Since: <day-name>, <day> <month> <year> <hour>:<minute>:<second> GMT
Directives: The HTTP If-Unmodified-Since header accept below described directives:
- <day-name>: It contains the day’s name like “Mon”, “Tue” etc. (case-sensitive).
- <day>: It contains the date in 2 digit numbers, like “04” or “23” for days.
- <month>: It contains the name of the month, in 3 letter month names like “Jan”, “Feb” etc.(case-sensitive).
- <year>: It contains the 4 digit year like “2009”
- <hour>: It contains the hour in 2 digit hour like “07” or “12”.
- <minute>: Same as hour minutes 2 digit minute like “09” or “55”
- <second>: Containing the seconds in 2 digit second like “08” or “50”.
- GMT: All the dates in HTTP will show in Greenwich Mean Time format, not in local time format.
- Below the header informing the server that it is not modified since 10th February 2004 which is Friday and mentioned time is 06:20:00, if that’s true then the request by the client will proceed.
If-Unmodified-Since: Fri, 10 Feb 2004 06:20:00 GMT
Note: This reduces bandwidth usage and improves the speed of your website.
Supported Browsers: The browsers are compatible with HTTP If-Unmodified-Since header are listed below:
- Google Chrome
- Internet Explorer