Performance: HTTP methods for CRUD operations
This concept affects the server response time and client-side rendering speed by how efficiently HTTP methods handle data operations.
Jump into concepts and practice - no test required
app.post('/items', (req, res) => { /* create */ }); app.get('/items/:id', (req, res) => { /* read */ }); app.put('/items/:id', (req, res) => { /* update */ }); app.delete('/items/:id', (req, res) => { /* delete */ });
app.post('/items', (req, res) => { /* create */ }); app.post('/items/read', (req, res) => { /* read */ }); app.post('/items/update', (req, res) => { /* update */ }); app.post('/items/delete', (req, res) => { /* delete */ });
| Pattern | Server Processing | Network Efficiency | Caching | Verdict |
|---|---|---|---|---|
| Using POST for all CRUD | High (all requests treated same) | Low (no caching benefits) | None | [X] Bad |
| Using correct HTTP methods | Low (clear routing) | High (GET can be cached) | Enabled | [OK] Good |
/users?PUT /items/5?
app.put('/items/:id', (req, res) => {
res.status(200).send(`Updated item ${req.params.id}`);
});app.delete('/users/:id', (req, res) => {
const userId = req.params;
deleteUser(userId);
res.send('User deleted');
});