Skip to content

3xx Redirection Codes — Redirecting Clients to New URLs

DodaTech Updated 2026-06-28 1 min read

In this tutorial, you will learn about 3xx redirection codes. We cover key concepts, practical examples, and best practices to help you master this topic.

3xx redirection codes tell clients that further action is needed, typically redirecting to a different URL for resource access, post-redirect-get patterns, or cache validation.

Code Reference

301 Moved Permanently: Resource URL changed permanently. Clients should update bookmarks. 302 Found: Temporary redirect for Load Balancing or maintenance. 303 See Other: POST-Redirect-GET pattern. Redirect after form submission. 304 Not Modified: Conditional GET with ETag. Response has no body.

Examples

// 301 Permanent redirect
app.get("/api/v1/users", (req, res) => {
  res.status(301)
    .location("/api/v2/users")
    .json({
      message: "This API version is deprecated. Use /api/v2/users",
      newUrl: "/api/v2/users"
    });
});

// 304 Not Modified with ETag
app.get("/api/users", async (req, res) => {
  const etag = await getCurrentEtag();
  if (req.headers["if-none-match"] === etag) {
    return res.status(304).send();
  }
  res.set("ETag", etag).json(await getUsers());
});

Common Mistakes

  1. Using 302 for permanent moves — Use 301 for permanent, 302 for temporary.
  2. No Location header — Redirects must include the target URL in Location.
  3. Body with 304 — 304 must have no body.

Practice Questions

  1. What is the difference between 301 and 302?
  2. When should you use 303 See Other?
  3. How does 304 Not Modified work with ETags?

What's Next

In the next lesson, you will learn 4xx client error codes.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro