Performance: Why REST principles matter
MEDIUM IMPACT
This affects how quickly and efficiently a web API responds to requests, impacting server response time and client rendering speed.
app.get('/users/1', (req, res) => { // returns only necessary user info following REST resource URL res.json({ id: 1, name: 'Alice' }); });
app.get('/getUserData', (req, res) => { // returns all user data including unnecessary nested info res.json({ user: { id: 1, name: 'Alice', password: 'secret', settings: { theme: 'dark', notifications: true } } }); });
| Pattern | Payload Size | Server Processing | Caching | Verdict |
|---|---|---|---|---|
| Non-RESTful API (large payload, unclear URLs) | High | High | No | [X] Bad |
| RESTful API (minimal payload, clear URLs) | Low | Low | Yes | [OK] Good |