With Valentine’s Day around the corner, it is a time for romantic hopefuls to ask out the object of their affection, and await an answer. It could be a simple “yes,” a sad “no,” or a cryptic “I don’t think about you that way, but maybe we can grab a coffee tomorrow?”
Which brings us to HTTP (Hypertext Transfer Protocol) codes . When a URL is typed in a browser, a request is sent out to the server and the browser awaits an answer, just like in our scenario. These answers come in the form of an HTTP code, which is a three-digit number that maps to an answer.
With the image of Valentine’s Day in mind, here are a few likely scenarios.
200s: The Happy Ending
Codes in the 200s generally mean that everything is OK. The request was received, understood, and there were no errors on the server. This URL will return a 200.
Codes in the 300s mean that the client must take further action to complete the request. The 300s are also where all redirects live.
A human will probably never see the 300 codes, as the browser is meant to seamlessly take the required action(s) without any user input. However, Search Engines will take these 300 codes seriously, so developers should take care to choose the correct code.
There is a subtle but important difference between 302, 303, and 307 which did not translate well into a comic.
The summary is that when 302 was first created, it was implemented incorrectly by popular browsers. To disambiguate between the right 302 and wrong 302, the 303 and 307 codes were created.
304s are useful to browsers because it signals that the resource can be loaded from cache, rather than having to download it from the server.
400s: Client Error
Errors in the 400s generally point to an issue with the request. It could be an issue with the browser, or the URL being used.
This is possibly the most famous of all error codes. Although many understand it to both mean “this resource doesn’t exist” and “this resource has been removed,” it actually makes no indication whether the resource has ever existed, or whether it will ever return.
Unlike the (in)famous 404, this is a case where a resource used to exist, but has been removed permanently, and is not expected to return. If you have removed a page from your website permanently, 410 should be used, rather than 404.
500s: Server Error
I hope scrolling through this post made HTTP codes a bit more interesting. For more technical explanations about these codes and more, check out some further reading below.