Performance: res.redirect for redirections
MEDIUM IMPACT
This affects page load speed by causing an additional HTTP request and response cycle before the final content loads.
app.get('/old-page', (req, res) => { res.status(200).sendFile(__dirname + '/path/to/new-page.html'); });
app.get('/old-page', (req, res) => { res.redirect('/new-page'); });
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| res.redirect causing extra HTTP request | N/A | N/A | Blocks initial paint until redirect completes | [X] Bad |
| Directly serving final content without redirect | N/A | N/A | Paints content on first response | [OK] Good |