Permanent Redirect
The resource has permanently moved to a new URI, and the HTTP method must be preserved.
What it means
The HTTP 308 Permanent Redirect redirect status response code indicates that the resource requested has been definitively moved to the URL given by the `Location` headers.
This has the exact same semantics as the 301 Moved Permanently HTTP response code, with the exception that the user agent must not change the HTTP method used: if a POST was used in the first request, a POST must be used in the second request.
How it works
- 1The client sends a POST request to an old API endpoint.
- 2The server responds with '308 Permanent Redirect' pointing to the v2 API endpoint.
- 3The client records this in its cache forever.
- 4The client sends the POST request to the v2 API.
Why you're seeing this
- • The endpoint permanently moved.
How to fix it
- • Update the client application code to use the new URL, saving the browser the extra round-trip time.
Framework Implementations
Express.js
app.post('/api/v1/user', (req, res) => {
res.redirect(308, '/api/v2/user');
});Real-Life Scenarios
Use this instead of 301 when permanently migrating APIs (POST/PUT/DELETE endpoints) to a new domain or path, to ensure clients don't mistakenly convert the request to a GET.
API v1 to v2 Migration
Deprecating /api/v1/submit and permanently pointing it to /api/v2/submit. Using 308 ensures the payload is safely transferred to v2.
HTTP Transaction
1. Client Request
POST /api/v1/user HTTP/1.1
Host: api.com
{"name": "John"}2. Server Response
HTTP/1.1 308 Permanent Redirect Location: /api/v2/user
SEO Implications
Like 301, it passes link equity to the new page. It is highly recommended for permanent redirects.