Status codes are issued by a server in response to a client’s request made to the server. They are classified into five different categories. In this way, it makes users easy to find the result of the requested process.
Every request sent by clients responds with an HTTP status code. Status codes live in the start lines of responses. For example, in the line “HTTP/1.1 200 OK” the status code is 200. The first digit of the status code defines which categories the message is from. The general meaning of HTTP status codes is shown below.
|Status Code||Status Code Category|
|100-199||informational response – the request was received, continuing process|
|200-299||successful – the request was successfully received, understood, and accepted|
|300-399||redirection – further action needs to be taken in order to complete the request|
|400-499||client error – the request contains bad syntax or cannot be fulfilled|
|500-599||server error – the server failed to fulfil an apparently valid request|
This table gives the overall idea of general response codes. The most common among these HTTP status codes are 3xx, 4xx, and 5xx. Let’s dig deeper about each of them in this section.
Most Common HTTP Status Codes
301 Status Code
When client send request to server, the server searched for the content but noticed that it has been move. Then, the server respond with code 301. After browser receives 301, it automatically redirects to the new location and respond accordingly.
The most common example of 301 status code is when switching a website from HTTP to HTTPS. You can read how to force HTTP to HTTPS redirect on this article.
302 Status Code
HTTP 302 status code is similar to the 301 except it is a temporary move. A browser redirects to this page but search engines don’t update their links to the resource. The new temporary address is given by the location field in the response.
304 Status Code
The browser sees the 304 Not Modified HTTP status code when a web page is up to date with the cached copy on the server. Essentially, this means that the page hasn’t changed since the last visit. This is used to speed up the website loading time using cache.
When browsers store data in their cache, they store the Last-Modified header data as well. In turn, this enables browsers to know exactly when the page was last modified. And when search engines look at the page and see that both header values are the same, the server returns the 304 code.
403 Status Code
The server respond with 403 status code when the user is trying to access the restricted page. You may have encountered this status code a lot if you surf internet a lot with different user accounts. There are many reasons why such status code appears.
Let’s take a simple example. You are logged in to web application as a User but trying to view a page that is only authorized to Admin. In such cases, you will encounter a 403 Permission Denied status code.
404 Status Code
This 404 status code is the most common of them all. It’s a “Not Found” response. When a user request for some resources on server, server looked for the content. If it doesn’t find anything, it will respond user with a 404 status code meaning it could not find anything on the URL.
The most common reason for this error is because of the wrong URL or content deletion by the owner. As a result, user try to access a page that doesn’t exist.
500 Status Code
A generic error message, given when an unexpected condition was encountered and no more specific message is suitable. Server respond with this status code when the server encounters an error that prevents it from servicing the request.
503 Status Code
The 503 Service Unavailable status code indicates that the website server is currently unavailable and, consequently, cannot process the incoming client request. In the vast majority of cases, the 503 status code appears if the server is too busy, as in it’s exceeding the limit on the number of concurrent users, or if the server’s undergoing maintenance works.