Performance: Refresh token concept
MEDIUM IMPACT
This concept affects the responsiveness and load on the server and client by managing authentication token renewal without frequent full logins.
app.post('/refresh-token', (req, res) => { const refreshToken = req.body.refreshToken; if (!refreshToken || !isValidRefreshToken(refreshToken)) { return res.status(403).send('Forbidden'); } const newAccessToken = generateAccessToken(refreshToken.user); res.json({ accessToken: newAccessToken }); });
app.get('/data', (req, res) => { const token = req.headers.authorization; if (!token || !isValid(token)) { return res.status(401).send('Unauthorized'); } // No refresh token, user must login again frequently fetchData().then(data => res.json(data)); });
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| No refresh token, frequent full login | Minimal | 0 | 0 | [X] Bad |
| Using refresh token for silent renewal | Minimal | 0 | 0 | [OK] Good |