What's the difference?
307vs308
Both lanes start with a POST. Watch that it is still a POST the second time, and who answers first.
- 307Temporary. The app answers each time, and the POST is sent again as a POST.
- 308Permanent. A cache has stored the redirect and answers by itself. The POST is still sent again as a POST.
How to tell them apart in 10 seconds
| Clue | 307 | 308 |
|---|---|---|
| How long it holds | For now. Keep using the original address | For good. Use the new address from now on |
| Method and body | Must be repeated unchanged | Must be repeated unchanged |
| Cached? | Only if the response says so | Yes by default |
| Older equivalent | 302, which lets POST become GET | 301, which lets POST become GET |
| Typical use | An API endpoint served elsewhere for a while | Forcing https or a new host for an API |
How long it holds
- 307
- For now. Keep using the original address
- 308
- For good. Use the new address from now on
Method and body
- 307
- Must be repeated unchanged
- 308
- Must be repeated unchanged
Cached?
- 307
- Only if the response says so
- 308
- Yes by default
Older equivalent
- 307
- 302, which lets POST become GET
- 308
- 301, which lets POST become GET
Typical use
- 307
- An API endpoint served elsewhere for a while
- 308
- Forcing https or a new host for an API
In short
307 vs 308: the difference
Both repeat the request unchanged. 307 is temporary; 308 is permanent and may be remembered.
307 and 308 exist to fix one weakness of the older redirects. With 301 and 302, a client is allowed to turn a POST into a GET when it follows the redirect, and most do, dropping the body on the way. 307 Temporary Redirect and 308 Permanent Redirect forbid that: the client must send the same method and the same body to the new address. Between the two, the only difference is how long the redirect holds. A 307 is temporary, like 302: clients keep using the original address and do not store the redirect unless told to. A 308 is permanent, like 301: clients should switch to the new address and may remember it. For pages that are only ever fetched with GET, they behave just like 302 and 301.
Your turn
Which one is this?
Which one is this? An API moves POST /v1/pay to /v2/pay permanently. Old clients must reach the new address with their payment data intact.
Each code in depth
- 307Temporary RedirectGo to another address for now, and repeat the request there exactly: same method, same body.
- Browser
- CDN
- Proxy
- App
- DB
- 308Permanent RedirectThis address has moved for good, and requests must be repeated at the new one unchanged.
- Browser
- CDN
- Proxy
- App
- DB
Questions
- What is the difference between 307 and 308?
- Both make the client repeat the request with the same method and body. A 307 is temporary, so clients keep using the original address. A 308 is permanent, so clients switch to the new one.
- When should I use 308 instead of 301?
- When requests with a body, such as POST or PUT, may hit the redirect. A 301 allows clients to turn them into GET; a 308 does not.
- Do all clients support 307 and 308?
- All current browsers do. A few old HTTP libraries do not recognise 308, or will not resend a request body on a redirect unless configured to.
Sources: RFC 9110: 307 Temporary Redirect (section 15.4.8) ↗ · RFC 9110: 308 Permanent Redirect (section 15.4.9) ↗ · Report a problem
Diagrams are our own simulations. All wording is original and paraphrases the linked sources.
Practise this in the DNS / HTTP track
Two-minute animated lessons, then boss fights from real outages. Free, no account needed.