Performance: PUT and PATCH route handling
MEDIUM IMPACT
This affects server response time and client perceived latency when updating resources via HTTP routes.
app.patch('/user/:id', (req, res) => { // expects partial user data const partialUpdate = req.body; // update only provided fields db.updateUserFields(req.params.id, partialUpdate); res.sendStatus(200); });
app.put('/user/:id', (req, res) => { // expects full user object const updatedUser = req.body; // replace entire user in DB db.updateUser(req.params.id, updatedUser); res.sendStatus(200); });
| Pattern | Payload Size | Server Processing | Network Latency | Verdict |
|---|---|---|---|---|
| PUT full update | Large (full resource) | High (process entire object) | High (larger data sent) | [X] Bad |
| PATCH partial update | Small (only changes) | Low (process few fields) | Low (smaller data sent) | [OK] Good |