HTTP Server Status

When a server answers a client request it gives an status code in the answer header that informs you if everything has gone ok or there has been any issue. Those statuses are divided in 5 groups:

  • 1xx: Informational.
  • 2xx: Success.
  • 3xx: Redirect commands. Very important in SEO.
  • 4xx: Client error.
  • 5xx: Server error.

Between them, the most common and the ones you may find while developing websites are these:

  • 100: Continue. The first part of the request is accepted and you should continue sending the rest if there was anything else to send. You may find it if working with AJAX or webservices.
  • 200: OK. The request has been answered without any problem.
  • 201: Created. When a new resource has succesfully been created due to the request.
  • 301: Moved permanently. Used when a page has moved to a new location, very important in SEO if you don’t want to lose PR.
  • 302: Found (Moved temporarily). This is the standard temporary redirection code.
  • 303: See other (Moved temporarily). If the request was a POST it has to be changed to GET in the new resource.
  • 307: Temporary redirect. Read down.
  • 400: Bad request. It happens when the user sets a querystring with manual data, for example.
  • 401: Unauthorized
  • 403: Forbidden
  • 404: Not found. One of the most popular.
  • 500: Internal Server Error. It happens a lot when working in localhost and should never happen in production.

Difference between 302, 303 and 307 redirects

Well, when a resource has changed its location temporarily and you send data using the POST method the client should ask you if you want to send that data to the new resource or not. Since that was a bit annoying for users browser-makers decided to skip the standard, not unaccomplisshing it, but doing something not specificated which was to convert the POST request in a GET request and make a GET to the new URI.

Technically they do not have to ask the user because its a GET request instead than a POST, but technically too they are not following the standard but skiping it with a trick (like if this were the Formula 1!). So the standard was updated and two new statuses were created: 303 and 307.

303 specifies that, yes, you should resend the POST data in a GET to the new URI, while 307 says that, by all means, you have to ask the user. 302 is then ambiguous (well, it really isn’t, but since its behavour was reinterpreted by browser-makers officially it should act as a 307 but in real life it is acting as a 303).

So there you have, standards and how developers do not follow them 🙂

There are more Server statuses at the w3.org.

Leave a Reply

Close Bitnami banner
Bitnami