HTTP 302 vs 307 — Temporary Redirect & Method Preservation Comparison
http 302 vs 307: both are temporary redirects, but 307 strictly preserves the HTTP method. When 307 fixes broken POST redirects in APIs and OAuth flows.
Quick Cheat Sheet
| Aspect | 302 Found | 307 Temporary Redirect |
|---|---|---|
| Permanence | Temporary | Temporary |
| Method preservation | MAY change POST → GET | MUST preserve method |
| Cacheable by default | No | No |
| Body preservation | MAY drop | MUST preserve |
| Original spec | HTTP/1.0 | HTTP/1.1 (RFC 2616, refined in 9110) |
Why 307 Exists
Just like 308 was created to fix 301's method-preservation bug, 307 Temporary Redirect was introduced to fix the same problem with 302. The HTTP/1.0 specification allowed 302 to mean "follow this URL with the same method," but in practice browsers nearly always converted POST → GET, eventually making that the de facto rule.
307 is the strict, unambiguous version: the method, headers, and body MUST all be preserved.
The Method-Preservation Difference
If a client makes POST /api/foo and gets back:
- 302 Location: /api/bar → most clients re-issue as
GET /api/bar(body lost, no Content-Type) - 307 Location: /api/bar → all compliant clients re-issue as
POST /api/barwith the original body
This is the only meaningful difference between the two codes.
When to Choose 307
Use 307 when:
- The redirect is for an API endpoint that accepts POST/PUT/PATCH/DELETE
- You need to preserve form data or JSON body across the redirect
- You're routing a webhook to a different endpoint based on payload inspection
Use 302 when:
- The redirect is for a GET-only web page (the vast majority of cases)
- You want the historical behavior of POST → GET conversion (rare but sometimes intentional)
- Maximum compatibility with truly ancient clients matters
OAuth and Single Sign-On
OAuth 2.0 and OIDC flows often involve redirecting authenticated POSTs across hosts. The OAuth spec recommends 303 (See Other) for the post-authorization redirect specifically because it forces a GET — you don't want the user's POST credentials forwarded to the redirect target.
When you genuinely want the method preserved (e.g., your auth proxy needs to internally redirect a POST without losing the body), 307 is the right choice.
Cacheability
Neither 302 nor 307 is cacheable by default — both are explicitly meant to be transient. If you need to cache a temporary redirect, send Cache-Control: max-age=N explicitly.
Real-World Example
A common API gateway pattern: incoming POST /webhooks is dynamically routed to one of several internal services based on a header. The gateway responds with 307 Location: https://internal-svc-2/webhooks so the original webhook payload (which can be a megabyte of JSON) is preserved.
If you used 302, the internal service would receive a GET with no body, breaking the webhook entirely.
Browser & Tooling Support
All modern browsers and HTTP clients (curl, requests, axios, fetch) correctly preserve method on 307. There are no significant compatibility issues today.
Real-World Use Case
An API gateway that A/B-tests two implementations of a webhook handler must use 307 to redirect POST /webhooks to either /v1/webhooks or /v2/webhooks — using 302 would lose the payload. For a GET-only marketing redirect during a short campaign (e.g., /spring-sale → /products?promo=spring), 302 is appropriate and easier for CDN edge cases.
Look Up Any Status Code
Related Comparisons
HTTP 301 vs 302 — Moved Permanently vs Found Comparison
http 301 vs 302: 301 is permanent and transfers SEO link equity, 302 is temporary. Learn the right choice for redirects and how Google, browsers, and CDNs treat each.
HTTP 301 vs 308 — Permanent Redirect & Method Preservation Comparison
http 301 vs 308: both are permanent redirects, but 308 strictly preserves the request method (POST stays POST). When to choose each for APIs vs web pages.
HTTP 303 vs 302 — See Other vs Found Status Code Comparison
http 303 vs 302: 303 is the canonical 'POST/Redirect/GET' code that always converts to GET, while 302 is ambiguous. Why 303 fixes form-resubmission in modern web apps.
HTTP 304 vs 200 — Not Modified vs OK (Caching) Comparison
http 304 vs 200: 304 is sent when a conditional GET hits an unchanged resource, saving bandwidth. Learn ETag, If-None-Match, and how 304 cuts CDN/origin costs.