Ever been to a website, clicked a link and seen "Error 401", or "HTTP Error 500", and wondered what on earth was going on? You're probably not alone. But, to really understand what these mean we need to understand how the web works.
When you visit a website - let's say getjanitor.com - your browser sends a request to our servers saying "Hey, I'd like to view the '/blog' page please". At this point the server responds. The response has 3 parts to it (it's a bit more technical than that, but for the sake of this example we'll stick with it):
- Status Code
- Headers
- Body
Skip Status Code for now and look at Headers. Headers are meta data about the request that help your browser do what it does. This is mostly bits of info that aren't particularly interesting such as the time/date of the request, timezone of the server, and some bits related to security.
Then there's the Body. The Body is simply the content of the page itself. If we're talking about the blog page then it's the content of that page - probably made up of the website logo, nav, list of blog posts and then a footer. It's the full HTML that makes up the entire page.
So back to Status Code. The Status Code is 3 numbers that tell the browser how the server is dealing with the request. This is your HTTP 500, HTTP 401, HTTP 404, etc.
The first number in the code tells the browser the kind of response to expect.
Success! 200
Most web pages return a HTTP 200 code. This tells the browser that everything is good and to expect the full body of the page.
Redirects. 300s
Anything in the 300 range is expected to be some sort of redirect. It tells the browser to go somewhere else, probably because the document/file doesn't exist any more.
There are 2 kinds of redirect.
302 - Temporary Redirect
A 302 happens when something has moved, but only temporarily. It's up to the browser what it chooses to do here. They'll all redirect the user to the new destination, but most won't cache the response, they'll check with the server every time.
301 - Permanent Redirect
You can probably guess what this is. The document has moved and it won't be coming back.
Client Issues. 400s
Anything beginning with a 4 in the 400 range is reserved for problems with the client interacting with the server. Although it could be, this isn't usually a problem with your browser specifically, but a problem with what you're trying to do.
There are a few different error codes here, and some of them are quite common.
400 - Bad Request
The request the browser sent is bad or malformed. This is one of the few requests which could be caused by a bug in your browser. It can also be caused by another program on your computer interfering with things (like an anti-virus app), an unstable internet connection or even the server software having a bad day.
401 - Unauthorized
You should have an account on the website to access this page.
403 - Forbidden
You don't have access to what you're trying to view. This is different to 401, because you could be logged in at the time, but you just don't have the right access. An example might be an admin area - you might be logged in as a normal user, but you tried to access to administration part of the website, but your user level isn't high enough to view it.
404 - Not Found
Probably the most popular HTTP error code. Nice and straightforward, the page/file just doesn't exist.
There are a lot more 400 error codes, but we won't go through them all. They cover things such as the wrong type of request being made, URL being too long, and there's even one where the server tells the browser it's a teapot.
Server Issues. 500s
The 500 range is reserved for the server telling the browser when it's not working quite right. A 500 error can be caused by all sorts of reasons.
500 - Internal Server Error
The most common HTTP 500 error is this one. It basically means the server tried to run some code but it failed, probably due to a bug or error in the code itself.
502 - Bad Gateway
Often you aren't communicating with a server, but a network of computers/servers doing different takes. Sometimes there are communication issues between them. These communication issues can often manifest themselves as a HTTP 502.
There are a few other 500 HTTP errors, but they're quite complicated and not seen very often. None as exciting as the server pretending to be a teapot though unfortunately.
HTTP Error Detection on Your Website
Janitor scans your site multiple times a day, and crawls the links on your website to check for common faults. Many of these issues include the HTTP issues listed above. In fact, Janitor checks for any error code other than a 200, 301 or 302, as they aren't what a user wants to see and should be fixed.
When any HTTP errors are found on your site Janitor will send you an email, a Slack notification and a notification on the website (you can disable Slack and email notifications if you need to).
You're also able to log into Janitor's dashboard and view any of the logs for your website at any time.