HTTP Response Status Codes: Redirection (300–399) — Grow Together By Sharing Knowledge

Sandeep Agrawal
3 min readAug 8, 2023

HTTP response status codes are crucial elements in web communication, providing vital information about the outcome of a client’s request.

In our previous blog posts, we explored Informational Responses (100–199) and Successful Responses (200–299), learning how they establish communication and indicate the success of a request.

Now, let’s embark on a journey through the third class of HTTP response status codes — Redirection Responses (300–399). These codes indicate that further action is needed to complete the client’s request. Join us as we delve into each of these redirection responses, understanding their meanings and use cases.

Table: HTTP Response Status Codes — Redirection Responses HTTP 3xx Status Codes (Redirection Responses)

300 Multiple Choices

  • Description: The requested resource has multiple choices, each with different locations. The server includes a Location header in the response to provide options for the client to follow.
  • Example: HTTP/1.1 300 Multiple Choices

301 Moved Permanently

  • Description: The requested resource has been permanently moved to a new location. The client should update its links to use the new URL in future requests.
  • Example: HTTP/1.1 301 Moved Permanently

302 Found / Moved Temporarily

  • Description: The requested resource is temporarily located elsewhere. The client should use the new URL for future requests, but the old URL may still be used in some cases.
  • Example: HTTP/1.1 302 Found or HTTP/1.1 302 Moved Temporarily

303 See Other

  • Description: The response to the request can be found under a different URI. The client should use a GET request to retrieve the resource from the new location.
  • Example: HTTP/1.1 303 See Other

304 Not Modified

  • Description: The client’s cached version of the requested resource is up to date, and there is no need to transfer the same content again. The server sends this response to save bandwidth and reduce unnecessary requests.
  • Example: HTTP/1.1 304 Not Modified

307 Temporary Redirect

  • Description: Similar to 302, but the client must preserve the request method when redirecting to the new URL. This ensures that non-GET requests, such as POST or PUT, are also redirected.
  • Example: HTTP/1.1 307 Temporary Redirect

308 Permanent Redirect

  • Description: The requested resource has been permanently moved to a new location. The client should update its links to use the new URL, and future requests should be directed there.
  • Example: HTTP/1.1 308 Permanent Redirect

Redirection responses (status codes 300–399) indicate that the client’s request cannot be completed as expected with the current URL. Instead, the server provides information about alternative locations where the requested resource can be found. These redirection responses play a crucial role in maintaining a smooth user experience when URLs change or resources are moved.

As a web developer, understanding these redirection responses helps in handling redirects properly and ensuring that users can access the right content even when URLs change.

Next, we’ll explore Client Error Responses (400–499), which indicate that the client’s request contains errors or cannot be fulfilled. Happy coding!

Visit Techtalkbook to find more related topics.

References https://developer.mozilla.org/en-US/docs/Web/HTTP/Status

Originally published at https://techtalkbook.com on August 8, 2023.

--

--